Changeset 38


Ignore:
Timestamp:
Jun 21, 2010, 9:13:56 PM (15 years ago)
Author:
dmik
Message:

jdk/hpi: Port windows/sys_api_md, system_md and threads_md to EMX/os2.

Location:
trunk/openjdk/jdk/src/windows/hpi/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/jdk/src/windows/hpi/src/sys_api_md.c

    r2 r38  
    3232#include <limits.h>
    3333
     34#ifdef __EMX__
     35
     36#ifdef __WIN32OS2__
     37#include <os2wrap2.h>
     38#endif
     39#include <windows.h>
     40#include <wincon.h>
     41
     42#define _stati64 stat
     43#define _fstati64 fstat
     44#define _lseeki64 lseek
     45
     46#endif /* EMX */
     47
    3448#include "hpi_impl.h"
    3549
     
    97111     *
    98112     */
     113#ifdef __WIN32OS2__
     114    os2_AVAILDATA avail = { 0, 0 };
     115    os2_ULONG pipeState;
     116    os2_APIRET arc = DosPeekNPipe(0, NULL, 0, NULL, &avail, &pipeState);
     117    // note that even if ERROR_INVALID_PARAMETER, it seems to return the
     118    // correct values in avail and state (undocumented)
     119    if (arc != NO_ERROR && arc != ERROR_INVALID_PARAMETER) {
     120        *pbytes = avail.cbpipe;
     121        return TRUE;
     122    }
     123
     124    return FALSE;
     125#else
    99126    HANDLE han;
    100127
     
    116143    }
    117144    return TRUE;
     145#endif
    118146}
    119147
     
    183211int
    184212sysSync(int fd) {
     213#ifdef __EMX__
     214    return fsync(fd);
     215#else /* __EMX__ */
    185216    /*
    186217     * From the documentation:
     
    208239    }
    209240    return 0;
     241#endif /* __EMX__ */
    210242}
    211243
     
    213245int
    214246sysSetLength(int fd, jlong length) {
     247#ifdef __EMX__
     248    return ftruncate(fd, length);
     249#else /* __EMX__ */
    215250    HANDLE h = (HANDLE)_get_osfhandle(fd);
    216251    long high = (long)(length >> 32);
     
    224259    if (SetEndOfFile(h) == FALSE) return -1;
    225260    return 0;
     261#endif /* __EMX__ */
    226262}
    227263
     
    236272    (*size) = buf64.st_size;
    237273
     274#ifndef __EMX__
    238275    if (*size & 0xFFFFFFFF00000000) {
    239276        /*
     
    266303
    267304    }
     305#endif /* !__EMX__ */
    268306    return 0;
    269307}
  • trunk/openjdk/jdk/src/windows/hpi/src/system_md.c

    r2 r38  
    2929#include <time.h>               /* For _tzset() and _ftime() */
    3030#include <errno.h>
     31
     32#ifdef __EMX__
     33#include <io.h>
     34#include <memory.h>
     35#endif /* __EMX__ */
    3136
    3237#include "hpi_impl.h"
     
    109114     * to, but by doing this here we ensure other dll's don't override.
    110115     */
     116#ifdef __EMX__
     117    _control87(MCW_EM | RC_NEAR | PC_53, MCW_EM | MCW_RC | MCW_PC);
     118#else
    111119    _control87(_MCW_EM | _RC_NEAR | _PC_53, _MCW_EM | _MCW_RC | _MCW_PC);
     120#endif /* __EMX__ */
    112121
    113122    InitializeMem();
  • trunk/openjdk/jdk/src/windows/hpi/src/threads_md.c

    r2 r38  
    6868#ifndef _WIN64
    6969    PNT_TIB nt_tib;
     70#ifdef __EMX__
     71    asm("movl %%fs:0x18, %%eax\n\t"
     72        "mov %%eax, %0\n\t"
     73        : "=m" (nt_tib) : : "%eax");
     74#else /* __EMX__ */
    7075    __asm {
    7176        mov eax, dword ptr fs:[18h];
    7277        mov nt_tib, eax;
    7378    }
     79#endif /* __EMX__ */
    7480    tid->nt_tib = nt_tib;
    7581#else
     
    216222    }
    217223
     224#ifdef __EMX__
     225    asm("mov %%ss, %%ax\n\t"
     226        "mov %%ax, %0\n\t"
     227        : "=m" (__current_SS) : : "%ax");
     228#else /* __EMX__ */
    218229    __asm {
    219230        mov ax, ss;
    220231        mov __current_SS, ax;
    221232    }
     233#endif /* __EMX__ */
    222234
    223235    if (context.SegSs == __current_SS &&
     
    317329    tid->start_proc(tid->start_parm);
    318330    sysThreadFree();
     331#ifdef __EMX__
     332    // @todo probably need to cause some per-thread LIBC termination routine
     333    ExitThread(0);
     334#else /* __EMX__ */
    319335    _endthreadex(0);
     336#endif /* __EMX__ */
    320337    /* not reached */
    321338    return 0;
     
    342359     * Start the new thread.
    343360     */
     361#ifdef __EMX__
     362    // @todo probably need to cause some per-thread LIBC initialization routine
     363    tid->handle = CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)_start,
     364                               tid, CREATE_SUSPENDED, (LPDWORD)&tid->id);
     365
     366#else /* __EMX__ */
    344367    tid->handle = (HANDLE)_beginthreadex(NULL, stack_size, _start, tid,
    345368                                         CREATE_SUSPENDED, &tid->id);
     369#endif /* __EMX__ */
    346370    if (tid->handle == 0) {
    347371        return SYS_NORESOURCE;  /* Will be treated as though SYS_NOMEM */
Note: See TracChangeset for help on using the changeset viewer.