Changeset 494 for trunk/src/emx/include


Ignore:
Timestamp:
Aug 1, 2003, 8:42:12 AM (22 years ago)
Author:
zap
Message:

See ChangeLog.

Location:
trunk/src/emx/include
Files:
3 added
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/386/builtin.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r493 r494  
    8787}
    8888
     89/* Quick routines similar to div() and friends, but inline */
     90
     91static __inline__ long __ldivmod (long num, long den, long *rem)
     92{
     93  long q, r;
     94  __asm__ ("cltd; idivl %2"
     95           : "=a" (q), "=&d" (r)
     96           : "r?m" (den), "a" (num));
     97  *rem = r;
     98  return q;
     99}
     100
     101static __inline__ unsigned long __uldivmod (unsigned long num,
     102  unsigned long den, unsigned long *rem)
     103{
     104  unsigned long q, r;
     105  __asm__ ("xorl %%edx,%%edx; divl %2"
     106           : "=a" (q), "=&d" (r)
     107           : "r?m" (den), "a" (num));
     108  *rem = r;
     109  return q;
     110}
     111
     112/*
     113    Divide a 64-bit integer by a 32-bit one:
     114
     115    A*2^32 + B    A            B + (A mod 32)
     116    ---------- = --- * 2^32 + ----------------
     117        C         C                  C
     118*/
     119static __inline__ long long __lldivmod (long long num, long den, long *rem)
     120{
     121  long long q;
     122  long r;
     123  __asm__ ("    movl    %%eax,%%esi;"
     124           "    movl    %%edx,%%eax;"
     125           "    pushl   %%edx;"
     126           "    cltd;"
     127           "    idivl   %2;"
     128           "    ;"
     129/* Now ensure remainder is smallest of possible two values (negative and
     130   positive). For this we compare the remainder with positive and negative
     131   denominator/2; if it is smaller than one and bigger than another we
     132   consider it optimal, otherwise it can be made smaller by adding or
     133   subtracting denominator to it. This is done to ensure no overflow
     134   will occur at next division. */
     135           "    movl    %2,%%ecx;"
     136           "    sarl    $1,%%ecx;"      /* ecx = den/2 */
     137           "    cmpl    %%ecx,%%edx;"
     138           "    setl    %%bl;"
     139           "    negl    %%ecx;"
     140           "    cmpl    %%ecx,%%edx;"
     141           "    setl    %%bh;"
     142           "    xorb    %%bh,%%bl;"
     143           "    jnz     1f;"            /* Remainder is between -den/2...den/2 */
     144           "    ;"
     145/* If remainder has same sign as denominator, we have to do r -= den; q++;
     146   otherwise we have to do r += den; q--; */
     147           "    movl    %2,%%ebx;"      /* ebx = den */
     148           "    xorl    %%edx,%%ebx;"   /* r ^ den */
     149           "    js      0f;"            /* Different signs */
     150           "    subl    %2,%%edx;"      /* r -= den */
     151           "    addl    $1,%%eax;"      /* q++ */
     152           "    adcl    $0,%%edx;"
     153           "    jmp     1f;"
     154           "    ;"
     155           "0:  addl    %2,%%edx;"      /* r += den */
     156           "    subl    $1,%%eax;"      /* q-- */
     157           "    sbbl    $0,%%edx;"
     158           "    ;"
     159           "1:  xchgl   %%eax,%%esi;"
     160           "    idivl   %2;"
     161           "    ;"
     162           "    movl    %%edx,%1;"
     163           "    cltd;"
     164           "    addl    %%esi,%%edx;"
     165           "    ;"
     166/* Check if numerator has the same sign as remainder; if they have different
     167   sign we should make the remainder have same sign as numerator to comply
     168   with ANSI standard, which says we always should truncate the quotient
     169   towards zero. */
     170           "    popl    %%ebx;"         /* ebx = num >> 32 */
     171           "    xorl    %1,%%ebx;"      /* sign(r) ^ sign(num) */
     172           "    jns     3f;"            /* jump if same sign */
     173           "    ;"
     174/* If remainder has same sign as denominator, we have to do r -= den; q++;
     175   otherwise we have to do r += den; q--; */
     176           "    movl    %2,%%ebx;"
     177           "    xorl    %1,%%ebx;"      /* r ^ den */
     178           "    js      2f;"            /* Different signs */
     179           "    subl    %2,%1;"         /* r -= den */
     180           "    addl    $1,%%eax;"      /* q++ */
     181           "    adcl    $0,%%edx;"
     182           "    jmp     3f;"
     183           "    ;"
     184           "2:  addl    %2,%1;"         /* r += den */
     185           "    subl    $1,%%eax;"      /* q-- */
     186           "    sbbl    $0,%%edx;"
     187           "    ;"
     188           "3:  ;"
     189           : "=A" (q), "=&c" (r)
     190           : "r" (den), "A" (num)
     191           : "ebx", "esi");
     192  *rem = r;
     193  return q;
     194}
     195
     196/*
     197    Same as __lldivmod except that if A < C, we can do just one division
     198    instead of two because the result is always a 32-bit integer.
     199*/
     200static __inline__ unsigned long long __ulldivmod (unsigned long long num,
     201  unsigned long den, unsigned long *rem)
     202{
     203  unsigned long long q;
     204  unsigned long r;
     205  __asm__ ("    movl    %%eax,%1;"
     206           "    movl    %%edx,%%eax;"
     207           "    xorl    %%edx,%%edx;"
     208           "    divl    %2;"
     209           "    xchgl   %%eax,%%ecx;"
     210           "    divl    %2;"
     211           "    xchgl   %%edx,%1;"
     212           : "=A" (q), "=c" (r)
     213           : "r?m" (den), "A" (num));
     214  *rem = r;
     215  return q;
     216}
     217
    89218#if defined (__cplusplus)
    90219}
  • trunk/src/emx/include/ctype.h

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r493 r494  
    1 /* ctype.h (emx+gcc) */
     1/*
     2    Locale support implementation through OS/2 Unicode API.
     3    Copyright (c) 2003 InnoTek Systemberatung GmbH
     4
     5    For conditions of distribution and use, see the file COPYING.
     6
     7    Character type querying.
     8*/
    29
    310#ifndef _CTYPE_H
     
    815#endif
    916
    10 extern unsigned char _ctype[];
     17#include <sys/locale.h>
    1118
    12 #define _UPPER  0x01
    13 #define _LOWER  0x02
    14 #define _DIGIT  0x04
    15 #define _XDIGIT 0x08
    16 #define _CNTRL  0x10
    17 #define _SPACE  0x20
    18 #define _PUNCT  0x40
    19 #define _PRINT  0x80
     19static inline int isalnum (int _c)
     20{ return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER|__DIGIT); }
    2021
    21 #if defined (__cplusplus)
     22static inline int isalpha (int _c)
     23{ return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER); }
    2224
    23 extern inline int isalnum (int _c)
    24   { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER|_DIGIT); }
    25 extern inline int isalpha (int _c)
    26   { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER); }
    27 extern inline int iscntrl (int _c)
    28   { return (_ctype+1)[(unsigned char)_c] & (_CNTRL); }
    29 extern inline int isdigit (int _c)
    30   { return (_ctype+1)[(unsigned char)_c] & (_DIGIT); }
    31 extern inline int isgraph (int _c)
    32   { return (_ctype+1)[(unsigned char)_c] & (_PUNCT|_UPPER|_LOWER|_DIGIT); }
    33 extern inline int islower (int _c)
    34   { return (_ctype+1)[(unsigned char)_c] & (_LOWER); }
    35 extern inline int isprint (int _c)
    36   { return (_ctype+1)[(unsigned char)_c] & (_PRINT); }
    37 extern inline int ispunct (int _c)
    38   { return (_ctype+1)[(unsigned char)_c] & (_PUNCT); }
    39 extern inline int isspace (int _c)
    40   { return (_ctype+1)[(unsigned char)_c] & (_SPACE); }
    41 extern inline int isupper (int _c)
    42   { return (_ctype+1)[(unsigned char)_c] & (_UPPER); }
    43 extern inline int isxdigit (int _c)
    44   { return (_ctype+1)[(unsigned char)_c] & (_XDIGIT); }
     25static inline int iscntrl (int _c)
     26{ return __locale_ctype.cflags [_c & 0xff] & (__CNTRL); }
    4527
    46 #else
     28static inline int isdigit (int _c)
     29{ return __locale_ctype.cflags [_c & 0xff] & (__DIGIT); }
    4730
    48 #define isalnum(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER|_DIGIT))
    49 #define isalpha(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER))
    50 #define iscntrl(c)  ((_ctype+1)[(unsigned char)c] & (_CNTRL))
    51 #define isdigit(c)  ((_ctype+1)[(unsigned char)c] & (_DIGIT))
    52 #define isgraph(c)  ((_ctype+1)[(unsigned char)c] & (_PUNCT|_UPPER|_LOWER|_DIGIT))
    53 #define islower(c)  ((_ctype+1)[(unsigned char)c] & (_LOWER))
    54 #define isprint(c)  ((_ctype+1)[(unsigned char)c] & (_PRINT))
    55 #define ispunct(c)  ((_ctype+1)[(unsigned char)c] & (_PUNCT))
    56 #define isspace(c)  ((_ctype+1)[(unsigned char)c] & (_SPACE))
    57 #define isupper(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER))
    58 #define isxdigit(c) ((_ctype+1)[(unsigned char)c] & (_XDIGIT))
     31static inline int isgraph (int _c)
     32{ return __locale_ctype.cflags [_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); }
    5933
    60 int (isalnum)(int);
    61 int (isalpha)(int);
    62 int (iscntrl)(int);
    63 int (isdigit)(int);
    64 int (isgraph)(int);
    65 int (islower)(int);
    66 int (isprint)(int);
    67 int (ispunct)(int);
    68 int (isspace)(int);
    69 int (isupper)(int);
    70 int (isxdigit)(int);
     34static inline int islower (int _c)
     35{ return __locale_ctype.cflags [_c & 0xff] & (__LOWER); }
    7136
    72 int toupper (int);
    73 int tolower (int);
    74 int _toupper (int);
    75 int _tolower (int);
     37static inline int isprint (int _c)
     38{ return __locale_ctype.cflags [_c & 0xff] & (__PRINT); }
    7639
    77 #endif
     40static inline int ispunct (int _c)
     41{ return __locale_ctype.cflags [_c & 0xff] & (__PUNCT); }
    7842
    79 #if !defined (_CTYPE_FUN)
    80 extern __inline__ int _toupper (int _c) { return (_c-'a'+'A'); }
    81 extern __inline__ int _tolower (int _c) { return (_c-'A'+'a'); }
    82 extern __inline__ int toupper(int _c)
    83   {return (islower(_c) ? _toupper(_c) : _c);}
    84 extern __inline__ int tolower(int _c)
    85   {return (isupper(_c) ? _tolower(_c) : _c);}
    86 #endif
     43static inline int isspace (int _c)
     44{ return __locale_ctype.cflags [_c & 0xff] & (__SPACE); }
     45
     46static inline int isupper (int _c)
     47{ return __locale_ctype.cflags [_c & 0xff] & (__UPPER); }
     48
     49static inline int isxdigit (int _c)
     50{ return __locale_ctype.cflags [_c & 0xff] & (__XDIGIT); }
     51
     52static inline int toupper (int _c)
     53{ return __locale_ctype.upcase [_c & 0xff]; }
     54
     55static inline int tolower (int _c)
     56{ return __locale_ctype.locase [_c & 0xff]; }
    8757
    8858#if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)
    8959
    90 int (toascii)(int);
    91 int (isascii)(int);
     60static inline int isascii (int _c)
     61{ return (unsigned)_c <= 0x7f; }
    9262
    93 #define isascii(c)  ((unsigned)(c) <= 0x7f)
    94 #define toascii(c)  ((c) & 0x7f)
     63static inline int toascii (int _c)
     64{ return _c & 0x7f; }
    9565
    9666#endif
    97 
    9867
    9968#if defined (__cplusplus)
  • trunk/src/emx/include/emx/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r493 r494  
    179179int __mkdir (__const__ char *name);
    180180int __newthread (int tid);
    181 int __nls_ctype (unsigned char *buf);
    182 void __nls_memupr (unsigned char *buf, size_t size);
    183181int __open (__const__ char *name, int flags, unsigned long size);
    184182int __pause (void);
  • trunk/src/emx/include/emx/thread.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r493 r494  
    3737  unsigned int    _th_rand;                 /* Used by rand() */
    3838  void          * _th_store;                /* Pointer to user data */
    39   int             _th_mblen_shift;          /* Shift state for mblen() */
    40   int             _th_mbtowc_shift;         /* Shift state for mbtowc() */
    41   int             _th_wctomb_shift;         /* Shift state for wctomb() */
    4239  char            _th_vollabel[12];         /* Used by _getvol() */
    4340  char            _th_error[28];            /* Used by strerror() */
     
    4643  char            _th_ttyname[32];          /* Used by ttyname() */
    4744  char            _th_inetntoa[16];         /* Used by inetntoa() */
    48   int             _th_reserved[971];        /* 4096 bytes, total */
     45  int             _th_reserved[974];        /* 4096 bytes, total */
    4946};
    5047
  • trunk/src/emx/include/locale.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r493 r494  
    1 /* locale.h (emx+gcc) */
     1/*
     2    Locale support implementation through OS/2 Unicode API.
     3    Copyright (c) 2003 InnoTek Systemberatung GmbH
     4
     5    For conditions of distribution and use, see the file COPYING.
     6
     7    POSIX locale implementation.
     8*/
    29
    310#ifndef _LOCALE_H
     
    815#endif
    916
    10 #if !defined (NULL)
    11 #if defined (__cplusplus)
    12 #define NULL 0
    13 #else
    14 #define NULL ((void *)0)
    15 #endif
    16 #endif
     17/* lconv and categories */
     18#include <sys/locale.h>
    1719
    18 #define LC_ALL          0
    19 #define LC_COLLATE      1
    20 #define LC_CTYPE        2
    21 #define LC_MONETARY     3
    22 #define LC_NUMERIC      4
    23 #define LC_TIME         5
    24 
    25 #define LC_C             "C"
    26 #define LC_C_FRANCE      "FRAN"
    27 #define LC_C_GERMANY     "GERM"
    28 #define LC_C_ITALY       "ITAL"
    29 #define LC_C_SPAIN       "SPAI"
    30 #define LC_C_UK          "UK"
    31 #define LC_C_USA         "USA"
    32 
    33 struct lconv
    34 {
    35   char *decimal_point;
    36   char *thousands_sep;
    37   char *grouping;
    38   char *int_curr_symbol;
    39   char *currency_symbol;
    40   char *mon_decimal_point;
    41   char *mon_thousands_sep;
    42   char *mon_grouping;
    43   char *positive_sign;
    44   char *negative_sign;
    45   char int_frac_digits;
    46   char frac_digits;
    47   char p_cs_precedes;
    48   char p_sep_by_space;
    49   char n_cs_precedes;
    50   char n_sep_by_space;
    51   char p_sign_posn;
    52   char n_sign_posn;
    53 };
    54 
    55 
    56 char *setlocale (int, __const__ char *);
    57 
    58 struct lconv *_localeconv (int);
    59 struct lconv *localeconv (void);
    60 
    61 #if defined (__CHAR_UNSIGNED__)
    62 #define localeconv() _localeconv (255)
    63 #else
    64 #define localeconv() _localeconv (127)
    65 #endif
     20/* Set current locale, if __locale is not NULL. Returns previous locale. */
     21extern char *setlocale (int category, __const__ char *locale);
     22/* Get information about current locale. */
     23extern struct lconv *localeconv (void);
    6624
    6725#if defined (__cplusplus)
  • trunk/src/emx/include/stdlib.h

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r493 r494  
    7979    int (*)(__const__ void *, __const__ void *));
    8080div_t div (int, int);
     81ldiv_t ldiv (long, long);
    8182void exit (int) __attribute__ ((__noreturn__));
    8283char *getenv (__const__ char *);
    83 ldiv_t ldiv (long, long);
    8484int mblen (__const__ char *, size_t);
    8585size_t mbstowcs (wchar_t *, __const__ char *, size_t);
     
    149149extern char **environ;
    150150
    151 extern __const__ char * __const__ sys_errlist[];
    152 extern __const__ int sys_nerr;
    153 
    154151extern __const__ unsigned char _osminor;
    155152extern __const__ unsigned char _osmajor;
     
    159156
    160157unsigned alarm (unsigned);
    161 int      brk(const void *);
     158int brk(const void *);
    162159int chdir (__const__ char *);
    163160char *gcvt (double, int, char *);
     
    169166int putenv (__const__ char *);
    170167int rmdir (__const__ char *);
    171 void    *sbrk(intptr_t);
     168void *sbrk(intptr_t);
    172169unsigned sleep (unsigned);
    173170void swab (__const__ void *, void *, size_t);
     
    181178void srandom (unsigned);                                /* BSD */
    182179
     180char *itoa (int, char *, int);
     181char *ltoa (long, char *, int);
     182char *ultoa (unsigned long, char *, int);
     183char *lltoa (long long, char *, int);
     184char *ulltoa (unsigned long long, char *, int);
     185
    183186#endif
    184187
     
    188191
    189192extern char **_environ;
    190 extern __const__ char * __const__ _sys_errlist[];
    191 extern __const__ int _sys_nerr;
    192193
    193194unsigned _alarm (unsigned);
    194 int      _brk(const void *);
     195int _brk(const void *);
    195196int _chdir (__const__ char *);
    196197char *_gcvt (double, int, char *);
     
    201202int _putenv (__const__ char *);
    202203int _rmdir (__const__ char *);
    203 void     *_sbrk(intptr_t);
     204void *_sbrk(intptr_t);
    204205unsigned _sleep (unsigned);
    205206void _swab (__const__ void *, void *, size_t);
     
    217218void _exit (int) __attribute__ ((__noreturn__));
    218219int _filesys (__const__ char *, char *, size_t);
    219 int _fncmp (__const__ unsigned char *, __const__ unsigned char *);
    220220char **_fnexplode (__const__ char *);
    221221void _fnexplodefree (char **);
     
    239239_lldiv_t _lldiv (long long, long long);
    240240char *_lltoa (long long, char *, int);
     241_uldiv_t _uldiv (unsigned long, unsigned long);
     242_ulldiv_t _ulldiv (unsigned long long, unsigned long long);
     243char *_itoa (int, char *, int);
    241244char *_ltoa (long, char *, int);
     245char *_ultoa (unsigned long, char *, int);
     246char *_lltoa (long long, char *, int);
     247char *_ulltoa (unsigned long long, char *, int);
    242248void _makepath (char *, __const__ char *, __const__ char *,
    243249    __const__ char *, __const__ char *);
     
    258264unsigned long long _strtoull (__const__ char *, char **, int);
    259265char _swchar (void);
    260 _uldiv_t _uldiv (unsigned long, unsigned long);
    261 _ulldiv_t _ulldiv (unsigned long long, unsigned long long);
    262 char *_ulltoa (unsigned long long, char *, int);
    263 char *_ultoa (unsigned long, char *, int);
    264266void _wildcard (int *, char ***);
    265267
  • trunk/src/emx/include/sys/errno.h

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r493 r494  
    4747#define _SYS_ERRNO_H /* bird: emx */
    4848
    49 #if !defined(_KERNEL) && !defined(__ASSEMBLER__) && !defined(_ERRNO) /* bird: emx */
    50 #include <sys/cdefs.h>
    51 __BEGIN_DECLS
    52 #define _ERRNO                        /* bird: emx */
    53 extern int * _errno(void);            /* bird: emx */
    54 __END_DECLS
    55 #define errno           (* _errno())  /* bird: emx */
     49#if !defined (_ERRNO) && !defined (__ASSEMBLER__)
     50#define _ERRNO
     51extern int *_errno (void);
     52#define errno (*_errno ())
     53#endif
     54
     55#ifndef __ASSEMBLER__
     56extern __const__ char * __const__ sys_errlist[];
     57extern __const__ int sys_nerr;
    5658#endif
    5759
     
    189191#endif /* _POSIX_SOURCE */
    190192
    191 #ifdef _KERNEL
    192 /* pseudo-errors returned inside kernel to modify return to process */
    193 #define ERESTART        (-1)            /* restart syscall */
    194 #define EJUSTRETURN     (-2)            /* don't modify regs, just return */
    195 #define ENOIOCTL        (-3)            /* ioctl not handled by this layer */
    196 #define EDIRIOCTL       (-4)            /* do direct ioctl in GEOM */
    197193#endif
    198 
    199 #endif
  • trunk/src/emx/include/sys/param.h

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r493 r494  
    180180#endif
    181181
     182#if defined (__cplusplus) && (__GNUC__ >= 2)
     183#  define MIN(a,b) (((a)<?(b))
     184#else
     185#  define MIN(a,b) (((a)<(b))?(a):(b))
     186#endif
     187#if defined (__cplusplus) && (__GNUC__ >= 2)
     188#  define MAX(a,b) (((a)>?(b))
     189#else
     190#  define MAX(a,b) (((a)>(b))?(a):(b))
     191#endif
    182192
    183193#if defined (__cplusplus)
  • trunk/src/emx/include/utils.h

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r493 r494  
    4444#endif
    4545
    46 #ifndef MIN
    47 #define MIN(a,b) (((a)<(b))?(a):(b))
    48 #define imin(x,y) MIN((x),(y))
    49 #define MAX(a,b) (((a)>(b))?(a):(b))
    50 #endif
    51 #ifndef min
    52 #define min(a,b) (((a)<(b))?(a):(b))
    53 #endif
     46/* MIN/MAX */
     47#include <sys/param.h>
    5448/* timercmp */
    5549#include <sys/time.h>
Note: See TracChangeset for help on using the changeset viewer.