~ubuntu-branches/ubuntu/raring/parrot/raring-proposed

« back to all changes in this revision

Viewing changes to config/auto/frames/test_exec_cygwin_c.in

  • Committer: Bazaar Package Importer
  • Author(s): Allison Randal
  • Date: 2011-07-30 18:45:03 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110730184503-34d4mprtfx6pt5h3
Tags: 3.6.0-1
* New upstream release
* debian/watch:
  - Modified regular expression to capture numbered directory name
    (patch from Dominique Dumont).
* debian/rules:
  - Split build-arch and build-indep, resolving lintian warning.
  - Update path to pbc_disassemble for manpage generation (patch
    from Dominique Dumont).
* debian/patches:
  - Added patch 02_fix_perl_interpreter_path.patch, resolving
    lintian warnings.
* debian/control:
  - Added DM-Upload-Allowed field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (C) 2008-2009, Parrot Foundation.
3
 
 
4
 
test for exec privs
5
 
*/
6
 
 
7
 
#include <stdio.h>
8
 
#include <stdlib.h>
9
 
#include <sys/mman.h>
10
 
#include <limits.h>
11
 
#include <errno.h>
12
 
#include <malloc.h>
13
 
#include <unistd.h>
14
 
#include <string.h>
15
 
#ifndef PAGE_SIZE
16
 
#  define PAGE_SIZE getpagesize()
17
 
#endif
18
 
#
19
 
 
20
 
/*
21
 
 * c equiv:
22
 
  int t() {
23
 
  return 1;
24
 
}
25
 
*/
26
 
 
27
 
char code[] = {
28
 
    0xB8, 0x01, 0, 0, 0,        /* movl $1, %eax */
29
 
    0xC3                        /* ret */
30
 
};
31
 
 
32
 
typedef int (*pf)(void);
33
 
 
34
 
int
35
 
main(int argc, char *argv[])
36
 
{
37
 
    pf t;
38
 
    char *p;
39
 
    int rc;
40
 
    int prot = PROT_READ;
41
 
 
42
 
    if (argc != 2) {
43
 
        fprintf(stderr, "usage: test 0 | 1\n");
44
 
        exit(1);
45
 
    }
46
 
 
47
 
    if (atoi(argv[1]))
48
 
        prot |= PROT_EXEC;
49
 
 
50
 
    p = memalign(PAGE_SIZE, PAGE_SIZE);
51
 
    memcpy(p, code, sizeof (code));
52
 
 
53
 
    t  = (pf) p;
54
 
    rc = mprotect(p, PAGE_SIZE, prot);
55
 
 
56
 
    if (rc) {
57
 
        fprintf(stderr, "p = %p  PAGE_SIZE = %d (0x%x)\n", p,
58
 
            PAGE_SIZE, PAGE_SIZE);
59
 
        perror("failure");
60
 
    }
61
 
 
62
 
    if (t() == 1)
63
 
        puts("ok");
64
 
    else
65
 
        return 1;
66
 
 
67
 
    return 0;
68
 
}
69
 
 
70
 
/*
71
 
 * Local variables:
72
 
 *   c-file-style: "parrot"
73
 
 * End:
74
 
 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
75
 
 */