Ignore:
Timestamp:
Apr 22, 2007, 10:57:48 AM (18 years ago)
Author:
bird
Message:

Applied patch from Paul (aka Creeping).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/essentials/dev-lang/perl/os2/os2.c

    r3187 r3188  
    2020 * Various Unix compatibility functions for OS/2
    2121 */
     22
     23#ifdef __KLIBC__
     24#define INSTALL_PREFIX "u:/perl"
     25#endif
    2226
    2327#include <stdio.h>
     
    661665    PIB *pib;
    662666   
     667#ifndef __KLIBC__
    663668    if (!(_emx_env & 0x200)) return 1; /* not OS/2. */
     669#endif
    664670    if (CheckOSError(DosGetInfoBlocks(&tib, &pib)))
    665671        return -1;
     
    675681    PIB *pib;
    676682   
     683#ifndef __KLIBC__
    677684    if (!(_emx_env & 0x200))
    678685        Perl_croak_nocontext("Can't set type on DOS"); /* not OS/2. */
     686#endif
    679687    if (CheckOSError(DosGetInfoBlocks(&tib, &pib)))
    680688        croak_with_os2error("Error getting info blocks");
     
    833841  ULONG rc, prio = sys_prio(pid);
    834842
     843#ifndef __KLIBC__
    835844  if (!(_emx_env & 0x200)) return 0; /* Nop if not OS/2. */
     845#endif
    836846  if (priors[(32 - val) >> 5] + 1 == (prio >> 8)) {
    837847      /* Do not change class. */
     
    867877  ULONG ret;
    868878
     879#ifndef __KLIBC__
    869880  if (!(_emx_env & 0x200)) return 0; /* Nop if not OS/2. */
     881#endif
    870882  ret = sys_prio(pid);
    871883  if (ret == PRIO_ERR) {
     
    952964    ULONG apptype;
    953965   
     966#ifndef __KLIBC__
    954967    if (!(_emx_env & 0x200))
    955968        Perl_croak_nocontext("file_type not implemented on DOS"); /* not OS/2. */
     969#endif
    956970    if (CheckOSError(DosQueryAppType(path, &apptype))) {
    957971        switch (rc) {
     
    973987/* global PL_Argv[] contains arguments. */
    974988
     989#ifndef __KLIBC__
    975990extern ULONG _emx_exception (   EXCEPTIONREPORTRECORD *,
    976991                                EXCEPTIONREGISTRATIONRECORD *,
    977992                                CONTEXTRECORD *,
    978993                                void *);
     994#endif
    979995
    980996int
     
    10161032      reread:
    10171033        force_shell = 0;
     1034#ifndef __KLIBC__
    10181035        if (_emx_env & 0x200) { /* OS/2. */
     1036#else
     1037         {
     1038#endif
    10191039            int type = file_type(real_name);
    10201040          type_again:
     
    12541274                           
    12551275                            if (!shell)
     1276#ifndef __KLIBC__
    12561277                                shell = ((_emx_env & 0x200)
    12571278                                         ? "c:/os2/cmd.exe"
    12581279                                         : "c:/command.com");
     1280#else
     1281                                shell = "c:/os2/cmd.exe";
     1282#endif
    12591283                            nargs = shell_opt ? 2 : 1;  /* shell file args */
    12601284                            exec_args[0] = shell;
     
    20562080        int number = SvTRUE(get_sv("OS2::nsyserror", TRUE));
    20572081
     2082#ifndef __KLIBC__
    20582083        if (!(_emx_env & 0x200)) return ""; /* Nop if not OS/2. */
     2084#endif
    20592085        if (rc == 0)
    20602086                return "";
     
    22622288                    to = dllname2buffer(aTHX_ b, bl);
    22632289                } else {                                /* No Perl present yet */
     2290
    22642291                    HMODULE self = find_myself();
    22652292                    APIRET rc = DosQueryModuleName(self, bl, b);
     
    22722299                            *to = '/';
    22732300                    to = b;
     2301
    22742302                }
    22752303                break;
     
    26182646  APIRET badrc;
    26192647
     2648#ifndef __KLIBC__
    26202649  if (!(_emx_env & 0x200))      /* DOS */
    26212650    return !_sleep2(ms);
    2622 
     2651#endif
    26232652  os2cp_croak(DosCreateEventSem(NULL,        /* Unnamed */
    26242653                                &hevEvent1,  /* Handle of semaphore returned */
     
    39984027        GV *gv;
    39994028
     4029#ifndef __KLIBC__
    40004030        if (_emx_env & 0x200) { /* OS/2 */
     4031#else
     4032            {
     4033#endif
    40014034            newXS("File::Copy::syscopy", XS_File__Copy_syscopy, file);
    40024035            newXS("Cwd::extLibpath", XS_Cwd_extLibpath, file);
     
    40554088        GvMULTI_on(gv);
    40564089        sv_setiv(GvSV(gv), exe_is_aout());
     4090#ifndef __KLIBC__
    40574091        gv = gv_fetchpv("OS2::emx_rev", TRUE, SVt_PV);
     4092#endif
    40584093        GvMULTI_on(gv);
     4094#ifndef __KLIBC__
    40594095        sv_setiv(GvSV(gv), _emx_rev);
    40604096        sv_setpv(GvSV(gv), _emx_vprt);
     4097#endif
    40614098        SvIOK_on(GvSV(gv));
     4099#ifndef __KLIBC__
    40624100        gv = gv_fetchpv("OS2::emx_env", TRUE, SVt_PV);
     4101#endif
    40634102        GvMULTI_on(gv);
     4103#ifndef __KLIBC__
    40644104        sv_setiv(GvSV(gv), _emx_env);
     4105#endif
    40654106        gv = gv_fetchpv("OS2::os_ver", TRUE, SVt_PV);
    40664107        GvMULTI_on(gv);
     
    40734114}
    40744115
     4116#ifndef __KLIBC__
    40754117extern void _emx_init(void*);
     4118#endif
    40764119
    40774120static void jmp_out_of_atexit(void);
     
    40804123#define FORCE_EMX_INIT_INSTALL_ATEXIT   2
    40814124
     4125#ifndef __KLIBC__
    40824126static void
    40834127my_emx_init(void *layout) {
     
    40954139                "popf\n" : : "r" (layout), "m" (old_esp)        );
    40964140}
    4097 
     4141#endif
    40984142struct layout_table_t {
    40994143    ULONG text_base;
     
    41154159};
    41164160
     4161#ifndef __KLIBC__
    41174162static ULONG
    41184163my_os_version() {
     
    41304175    return osv_res;
    41314176}
    4132 
     4177#endif
     4178
     4179#ifndef __KLIBC__
    41334180static void
    41344181force_init_emx_runtime(EXCEPTIONREGISTRATIONRECORD *preg, ULONG flags)
     
    42354282        exit(56);
    42364283}
    4237 
     4284#endif
    42384285static void
    42394286jmp_out_of_atexit(void)
     
    42824329#include <emx/startup.h>
    42834330
     4331#ifndef __KLIBC__
    42844332extern ULONG __os_version();            /* See system.doc */
    4285 
     4333#endif
     4334
     4335#ifndef __KLIBC__
    42864336void
    42874337check_emx_runtime(char **env, EXCEPTIONREGISTRATIONRECORD *preg)
     
    43394389        initialized either.  Uninitialized EMX.DLL returns 0 in the low
    43404390        nibble of __os_version().  */
     4391
    43414392    v_emx = my_os_version();
    43424393
     
    43504401    v_crt = (_osmajor | _osminor);
    43514402
     4403#ifndef __KLIBC__
    43524404    if ((_emx_env & 0x200) && !(v_emx & 0xFFFF)) {      /* OS/2, EMX uninit. */
    43534405        force_init_emx_runtime( preg,
    43544406                                FORCE_EMX_INIT_CONTRACT_ARGV
    43554407                                | FORCE_EMX_INIT_INSTALL_ATEXIT );
     4408#endif
    43564409        emx_wasnt_initialized = 1;
    43574410        /* Update CRTL data basing on now-valid EMX runtime data */
     
    43924445        DosReleaseMutexSem(hmtx_emx_init);
    43934446}
    4394 
     4447#endif
    43954448#define ENTRY_POINT 0x10000
    43964449
     
    44304483    MALLOC_INIT;
    44314484
     4485#ifndef __KLIBC__
    44324486    check_emx_runtime(env, (EXCEPTIONREGISTRATIONRECORD *)preg);
    4433 
     4487#endif
    44344488    settmppath();
    44354489    OS2_Perl_data.xs_init = &Xs_OS2_init;
     
    44424496        Newx(PL_sh_path, strlen(SH_PATH) + 1, char);
    44434497        strcpy(PL_sh_path, SH_PATH);
     4498#ifndef __KLIBC__
    44444499        PL_sh_path[0] = shell[0];
     4500#endif
    44454501    } else if ( (shell = getenv("PERL_SH_DIR")) ) {
    44464502        int l = strlen(shell), i;
     
    44514507        strncpy(PL_sh_path, shell, l);
    44524508        strcpy(PL_sh_path + l, "/sh.exe");
     4509#ifndef __KLIBC__
    44534510        for (i = 0; i < l; i++) {
    44544511            if (PL_sh_path[i] == '\\') PL_sh_path[i] = '/';
    44554512        }
     4513#endif
    44564514    }
    44574515#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
     
    44944552    static ULONG max_fh = 0;
    44954553
     4554#ifndef __KLIBC__
    44964555    if (!(_emx_env & 0x200)) return 1;          /* not OS/2. */
     4556#endif
    44974557    if (fd >= max_fh) {                         /* Renew */
    44984558        LONG delta = 0;
     
    46294689   MUTEX_UNLOCK(&perlos2_state_mutex);
    46304690  }
     4691#ifndef __KLIBC__
    46314692  if (!(_emx_env & 0x200) || !use_my_flock)
    46324693    return flock(handle, o);    /* Delegate to EMX. */
     4694#endif
    46334695 
    46344696                                        /* is this a file? */
     
    47694831}
    47704832
     4833#ifndef __KLIBC__
    47714834void
    47724835setgrent(void)
     
    47874850  return getgrgid(0);
    47884851}
    4789 
     4852#endif
    47904853#undef getpwuid
    47914854#undef getpwnam
Note: See TracChangeset for help on using the changeset viewer.