Ticket #1105: config_fixup.patch

File config_fixup.patch, 13.1 KB (added by plobsing, 12 years ago)

remove exec protect checking from config::auto::frames, remove frame building checking from config::auto::libjit, small codingstd fixes

  • MANIFEST

     
    11# ex: set ro: 
    22# $Id$ 
    33# 
    4 # generated by tools/dev/mk_manifest_and_skip.pl Sat Oct 17 13:02:10 2009 UT 
     4# generated by tools/dev/mk_manifest_and_skip.pl Thu Oct 22 02:09:46 2009 UT 
    55# 
    66# See below for documentation on the format of this file. 
    77# 
     
    233233config/auto/env/test_unsetenv_c.in                          [] 
    234234config/auto/format.pm                                       [] 
    235235config/auto/frames.pm                                       [] 
    236 config/auto/frames/test_exec_cygwin_c.in                    [] 
    237 config/auto/frames/test_exec_linux_c.in                     [] 
    238 config/auto/frames/test_exec_openbsd_c.in                   [] 
    239236config/auto/gc.pm                                           [] 
    240237config/auto/gc/test_c.in                                    [] 
    241238config/auto/gcc.pm                                          [] 
  • lib/Parrot/Distribution.pm

     
    433433            include/parrot/config.h 
    434434            include/parrot/has_header.h 
    435435            src/gc/malloc.c 
     436            src/frame_builder_libjit.h 
     437            src/frame_builder_libjit.c 
    436438            } unless @exemptions; 
    437439 
    438440        my $path = -f $file ? $file : $file->path; 
  • t/steps/auto/libjit-01.t

     
    66use strict; 
    77use warnings; 
    88 
    9 use Test::More tests => 40; 
     9use Test::More tests => 34; 
    1010use lib qw( lib t/configure/testlib ); 
    1111use Parrot::Configure; 
    1212use Parrot::Configure::Options 'process_options'; 
     
    105105 
    106106my $extra_libs; 
    107107 
    108 $conf->data->set( 'cc_build_call_frames' => undef ); 
    109 $conf->data->set( 'has_exec_protect' => undef ); 
    110108$conf->data->set( 'libjit_has_alloca' => undef ); 
    111109$conf->data->set( 'libs' => '' ); 
    112110 
     
    115113$conf->data->set( 'cpuarch' => 'i386' ); 
    116114 
    117115auto::libjit::_handle_has_libjit($conf, $has_libjit, $extra_libs); 
    118 is( $conf->data->get( 'cc_build_call_frames' ), '-DCAN_BUILD_CALL_FRAMES', 
    119     "Got expected value for cc_build_call_frames" ); 
    120 ok( $conf->data->get( 'has_exec_protect' ), "has_exec_protect' set" ); 
    121116ok( $conf->data->get( 'libjit_has_alloca'), 
    122117    "on i386 with libJIT, 'libjit_has_alloca' has true value" ); 
    123118is( $conf->data->get( 'libs' ), " $extra_libs", 
    124119    "Got expected value for libs" ); 
    125120 
    126 $conf->data->set( 'cc_build_call_frames' => undef ); 
    127 $conf->data->set( 'has_exec_protect' => undef ); 
    128121$conf->data->set( 'libjit_has_alloca' => undef ); 
    129122$conf->data->set( 'libs' => '' ); 
    130123 
     
    133126$conf->data->set( 'cpuarch' => 'ppc' ); 
    134127 
    135128auto::libjit::_handle_has_libjit($conf, $has_libjit, $extra_libs); 
    136 is( $conf->data->get( 'cc_build_call_frames' ), '-DCAN_BUILD_CALL_FRAMES', 
    137     "Got expected value for cc_build_call_frames" ); 
    138 ok( $conf->data->get( 'has_exec_protect' ), "has_exec_protect' set" ); 
    139129ok( ! $conf->data->get( 'libjit_has_alloca'), 
    140130    "on non-i386 with libJIT, 'libjit_has_alloca' has false value" ); 
    141131is( $conf->data->get( 'libs' ), " $extra_libs", 
    142132    "Got expected value for libs" ); 
    143133 
    144 $conf->data->set( 'cc_build_call_frames' => undef ); 
    145 $conf->data->set( 'has_exec_protect' => undef ); 
    146134$conf->data->set( 'libjit_has_alloca' => undef ); 
    147135$conf->data->set( 'libs' => '' ); 
    148136 
     
    150138$extra_libs = 'mylibs'; 
    151139 
    152140auto::libjit::_handle_has_libjit($conf, $has_libjit, $extra_libs); 
    153 ok( ! defined($conf->data->get( 'cc_build_call_frames' )),  
    154     "cc_build_call_frames undefined as expected" ); 
    155 ok( ! defined($conf->data->get( 'has_exec_protect' )), 
    156     "has_exec_protect' undefined" ); 
    157141ok( ! $conf->data->get( 'libjit_has_alloca'), 
    158142    "without libJIT, 'libjit_has_alloca' has false value" ); 
    159143is( $conf->data->get( 'libs' ), "", 
  • t/steps/auto/frames-01.t

     
    8484 
    8585##### _handle_call_frames_buildable() ##### 
    8686 
    87 #$conf->data->set( nvsize => 8 ); 
    88 #$conf->data->set( cpuarch => 'i386' ); 
    89 $conf->data->set( osname => 'linux' ); 
    90  
    9187my $rv; 
    9288 
    9389$can_build_call_frames = 0; 
     
    10399$conf->data->set( 'has_exec_protect' => undef ); 
    104100 
    105101$can_build_call_frames = 1; 
    106 my $realos = $conf->data->get( 'osname' ); 
    107 $conf->data->set( 'osname' => 'foobar' ); 
    108102$rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames ); 
    109103ok( $rv, "_handle_can_build_call_frames() returned true value" ); 
    110104is( $conf->data->get( 'cc_build_call_frames'), '-DCAN_BUILD_CALL_FRAMES', 
    111105    "cc_build_call_frames set to expected value" ); 
    112 is( $conf->data->get( 'has_exec_protect' ), 0, 
    113     "has_exec_protect is 0, as expected" ); 
     106is( $conf->data->get( 'has_exec_protect' ), 1, 
     107    "has_exec_protect is 1, as expected" ); 
    114108is( $step->result(), 'yes', "Result is 'yes', as expected" ); 
    115109 
    116110$conf->data->set( 'cc_build_call_frames' => undef ); 
    117111$conf->data->set( 'has_exec_protect' => undef ); 
    118 $conf->data->set( 'osname' => $realos ); 
    119112 
    120113pass("Completed all tests in $0"); 
    121114 
  • config/auto/libjit.pm

     
    9393    my ($conf, $has_libjit, $extra_libs) = @_; 
    9494    if ($has_libjit) { 
    9595        $conf->data->set( 
    96             cc_build_call_frames => '-DCAN_BUILD_CALL_FRAMES', 
    97             has_exec_protect     => 1, 
    9896            libjit_has_alloca    => ($conf->data->get('cpuarch') eq 'i386' ? '1' : '0'), 
    9997        ); 
    10098        $conf->data->add( ' ', libs => $extra_libs ); 
  • config/auto/frames.pm

     
    5555    my ($self, $conf, $can_build_call_frames) = @_; 
    5656    if ( $can_build_call_frames ) { 
    5757        $conf->data->set( 
    58             cc_build_call_frames  => '-DCAN_BUILD_CALL_FRAMES', 
     58            cc_build_call_frames => '-DCAN_BUILD_CALL_FRAMES', 
     59            has_exec_protect     => 1, 
    5960        ); 
    60         # test for executable malloced memory 
    61         my $osname = $conf->data->get( 'osname' ); 
    62         if ( -e "config/auto/frames/test_exec_${osname}_c.in" ) { 
    63             $conf->cc_gen("config/auto/frames/test_exec_${osname}_c.in"); 
    64             eval { $conf->cc_build(); }; 
    65             if ($@) { 
    66                 $conf->data->set( has_exec_protect => 0 ); 
    67             } 
    68             else { 
    69                 my $exec_protect_test = ( 
    70                     $conf->cc_run(0) !~ /ok/ && $conf->cc_run(1) =~ /ok/ 
    71                 ); 
    72                 if ($exec_protect_test) { 
    73                     $conf->data->set( has_exec_protect => 1 ); 
    74                 } 
    75                 else { 
    76                     $conf->data->set( has_exec_protect => 0 ); 
    77                 } 
    78             } 
    79             $conf->cc_clean(); 
    80         } 
    81         else { 
    82             $conf->data->set( has_exec_protect => 0 ); 
    83         } 
    8461        $self->set_result( 'yes' ); 
    8562    } 
    8663    else { 
    87         $conf->data->set( cc_build_call_frames  => ''); 
     64        $conf->data->set(cc_build_call_frames  => ''); 
    8865        $self->set_result( 'no' ); 
    8966    } 
    9067    return 1; 
  • config/auto/frames/test_exec_openbsd_c.in

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

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

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

     
    1919 
    2020#ifdef PARROT_HAS_LIBJIT 
    2121 
    22 #include <jit/jit.h> 
     22#  include <jit/jit.h> 
    2323 
    2424/* 
    2525 * JITted function state data 
     
    3333 * JIT types 
    3434 */ 
    3535 
    36 #define JIT_TYPE_UINTVAL  @libjit_uv@ 
    37 #define JIT_TYPE_INTVAL   @libjit_iv@ 
    38 #define JIT_TYPE_FLOATVAL @libjit_nv@ 
     36#  define JIT_TYPE_UINTVAL  @libjit_uv@ 
     37#  define JIT_TYPE_INTVAL   @libjit_iv@ 
     38#  define JIT_TYPE_FLOATVAL @libjit_nv@ 
    3939 
    4040/* 
    4141 * JIT functions 
     
    6363/* 
    6464 * workaround for platforms that lack libjit alloca support 
    6565 */ 
    66 #if @libjit_has_alloca@ 
    67 define JIT_ALLOCA(f, n)      jit_insn_alloca(f, n) 
    68 define JIT_ALLOCA_FREE(f, p) 
    69 #else 
    70 define JIT_ALLOCA(f, n)      jit__mem_sys_allocate(f, n) 
    71 define JIT_ALLOCA_FREE(f, p) jit__mem_sys_free(f, p) 
    72 #endif 
     66#  if @libjit_has_alloca@ 
     67  define JIT_ALLOCA(f, n)      jit_insn_alloca((f), (n)) 
     68  define JIT_ALLOCA_FREE(f, p) 
     69#  else 
     70  define JIT_ALLOCA(f, n)      jit__mem_sys_allocate((f), (n)) 
     71  define JIT_ALLOCA_FREE(f, p) jit__mem_sys_free((f), (p)) 
     72#  endif 
    7373 
    7474/* 
    7575 * JIT wrappers