Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4874 Rev 4921
Line 9... Line 9...
9
extern "C" {
9
extern "C" {
10
#endif
10
#endif
11
#define _SYS_REENT_H_
11
#define _SYS_REENT_H_
Line 12... Line 12...
12
 
12
 
-
 
13
#include <_ansi.h>
13
#include <_ansi.h>
14
#include 
Line 14... Line 15...
14
#include 
15
#include 
Line 15... Line 16...
15
 
16
 
Line 83... Line 84...
83
	struct	_atexit *_next;			/* next in list */
84
	struct	_atexit *_next;			/* next in list */
84
	int	_ind;				/* next index in this table */
85
	int	_ind;				/* next index in this table */
85
	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
86
	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
86
        struct _on_exit_args * _on_exit_args_ptr;
87
        struct _on_exit_args * _on_exit_args_ptr;
87
};
88
};
-
 
89
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, _NULL}
88
#else
90
#else
89
struct _atexit {
91
struct _atexit {
90
	struct	_atexit *_next;			/* next in list */
92
	struct	_atexit *_next;			/* next in list */
91
	int	_ind;				/* next index in this table */
93
	int	_ind;				/* next index in this table */
92
	/* Some entries may already have been called, and will be NULL.  */
94
	/* Some entries may already have been called, and will be NULL.  */
93
	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
95
	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
94
        struct _on_exit_args _on_exit_args;
96
        struct _on_exit_args _on_exit_args;
95
};
97
};
-
 
98
# define _ATEXIT_INIT {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}
-
 
99
#endif
-
 
100
 
-
 
101
#ifdef _REENT_GLOBAL_ATEXIT
-
 
102
# define _REENT_INIT_ATEXIT
-
 
103
#else
-
 
104
# define _REENT_INIT_ATEXIT \
-
 
105
  _NULL, _ATEXIT_INIT,
96
#endif
106
#endif
Line 97... Line 107...
97
 
107
 
98
/*
108
/*
99
 * Stdio buffers.
109
 * Stdio buffers.
Line 181... Line 191...
181
 
191
 
182
  /* operations */
192
  /* operations */
Line 183... Line 193...
183
  _PTR	_cookie;	/* cookie passed to io functions */
193
  _PTR	_cookie;	/* cookie passed to io functions */
184
 
194
 
185
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
195
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
186
					   char *, int));
196
					   char *, _READ_WRITE_BUFSIZE_TYPE));
-
 
197
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
187
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
198
					    const char *,
188
					    const char *, int));
199
					    _READ_WRITE_BUFSIZE_TYPE));
Line 189... Line 200...
189
  _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
200
  _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
190
  int _EXFNPTR(_close, (struct _reent *, _PTR));
201
  int _EXFNPTR(_close, (struct _reent *, _PTR));
Line 201... Line 212...
201
  /* separate buffer for fgetline() when line crosses buffer boundary */
212
  /* separate buffer for fgetline() when line crosses buffer boundary */
202
  struct __sbuf _lb;	/* buffer for fgetline() */
213
  struct __sbuf _lb;	/* buffer for fgetline() */
Line 203... Line 214...
203
 
214
 
204
  /* Unix stdio files get aligned to block boundaries on fseek() */
215
  /* Unix stdio files get aligned to block boundaries on fseek() */
205
  int	_blksize;	/* stat.st_blksize (may be != _bf._size) */
216
  int	_blksize;	/* stat.st_blksize (may be != _bf._size) */
Line 206... Line 217...
206
  int	_offset;	/* current lseek offset */
217
  _off_t _offset;	/* current lseek offset */
207
 
218
 
208
#ifndef _REENT_SMALL
219
#ifndef _REENT_SMALL
Line 236... Line 247...
236
 
247
 
237
  /* operations */
248
  /* operations */
Line 238... Line 249...
238
  _PTR	_cookie;	/* cookie passed to io functions */
249
  _PTR	_cookie;	/* cookie passed to io functions */
239
 
250
 
240
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
251
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
241
					   char *, int));
252
					   char *, _READ_WRITE_BUFSIZE_TYPE));
-
 
253
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
242
  _READ_WRITE_RETURN_TYPE _EXFNPTR(_write, (struct _reent *, _PTR,
254
					    const char *,
243
					    const char *, int));
255
					    _READ_WRITE_BUFSIZE_TYPE));
Line 244... Line 256...
244
  _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
256
  _fpos_t _EXFNPTR(_seek, (struct _reent *, _PTR, _fpos_t, int));
245
  int _EXFNPTR(_close, (struct _reent *, _PTR));
257
  int _EXFNPTR(_close, (struct _reent *, _PTR));
Line 351... Line 363...
351
  _mbstate_t _mbsrtowcs_state;
363
  _mbstate_t _mbsrtowcs_state;
352
  _mbstate_t _wcrtomb_state;
364
  _mbstate_t _wcrtomb_state;
353
  _mbstate_t _wcsrtombs_state;
365
  _mbstate_t _wcsrtombs_state;
354
};
366
};
Line 355... Line 367...
355
 
367
 
356
/* This version of _reent is layed our with "int"s in pairs, to help
368
/* This version of _reent is laid out with "int"s in pairs, to help
357
 * ports with 16-bit int's but 32-bit pointers, align nicely.  */
369
 * ports with 16-bit int's but 32-bit pointers, align nicely.  */
358
struct _reent
370
struct _reent
359
{
371
{
360
  /* As an exception to the above put _errno first for binary
372
  /* As an exception to the above put _errno first for binary
Line 390... Line 402...
390
  char *_asctime_buf;
402
  char *_asctime_buf;
Line 391... Line 403...
391
 
403
 
392
  /* signal info */
404
  /* signal info */
Line -... Line 405...
-
 
405
  void (**(_sig_func))(int);
393
  void (**(_sig_func))(int);
406
 
394
 
407
# ifndef _REENT_GLOBAL_ATEXIT
395
  /* atexit stuff */
408
  /* atexit stuff */
-
 
409
  struct _atexit *_atexit;
Line 396... Line 410...
396
  struct _atexit *_atexit;
410
  struct _atexit _atexit0;
397
  struct _atexit _atexit0;
411
# endif
398
 
412
 
399
  struct _glue __sglue;			/* root of glue chain */
413
  struct _glue __sglue;			/* root of glue chain */
Line 423... Line 437...
423
    _NULL, \
437
    _NULL, \
424
    _NULL, \
438
    _NULL, \
425
    _NULL, \
439
    _NULL, \
426
    _NULL, \
440
    _NULL, \
427
    _NULL, \
441
    _NULL, \
428
    _NULL, \
-
 
429
    {_NULL, 0, {_NULL}, _NULL}, \
442
    _REENT_INIT_ATEXIT \
430
    {_NULL, 0, _NULL}, \
443
    {_NULL, 0, _NULL}, \
431
    _NULL, \
444
    _NULL, \
432
    _NULL, \
445
    _NULL, \
433
    _NULL \
446
    _NULL \
434
  }
447
  }
Line 435... Line 448...
435
 
448
 
-
 
449
#define _REENT_INIT_PTR(var) \
436
#define _REENT_INIT_PTR(var) \
450
  { memset((var), 0, sizeof(*(var))); \
437
  { (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
451
    (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
438
    (var)->_stdout = (__FILE *)&__sf_fake_stdout; \
452
    (var)->_stdout = (__FILE *)&__sf_fake_stdout; \
439
    (var)->_stderr = (__FILE *)&__sf_fake_stderr; \
-
 
440
    (var)->_errno = 0; \
-
 
441
    (var)->_inc = 0; \
-
 
442
    (var)->_emergency = _NULL; \
-
 
443
    (var)->__sdidinit = 0; \
-
 
444
    (var)->_current_category = 0; \
453
    (var)->_stderr = (__FILE *)&__sf_fake_stderr; \
445
    (var)->_current_locale = "C"; \
-
 
446
    (var)->_mp = _NULL; \
-
 
447
    (var)->__cleanup = _NULL; \
-
 
448
    (var)->_gamma_signgam = 0; \
-
 
449
    (var)->_cvtlen = 0; \
-
 
450
    (var)->_cvtbuf = _NULL; \
-
 
451
    (var)->_r48 = _NULL; \
-
 
452
    (var)->_localtime_buf = _NULL; \
-
 
453
    (var)->_asctime_buf = _NULL; \
-
 
454
    (var)->_sig_func = _NULL; \
-
 
455
    (var)->_atexit = _NULL; \
-
 
456
    (var)->_atexit0._next = _NULL; \
-
 
457
    (var)->_atexit0._ind = 0; \
-
 
458
    (var)->_atexit0._fns[0] = _NULL; \
-
 
459
    (var)->_atexit0._on_exit_args_ptr = _NULL; \
-
 
460
    (var)->__sglue._next = _NULL; \
-
 
461
    (var)->__sglue._niobs = 0; \
-
 
462
    (var)->__sglue._iobs = _NULL; \
-
 
463
    (var)->__sf = 0; \
-
 
464
    (var)->_misc = _NULL; \
-
 
465
    (var)->_signal_buf = _NULL; \
454
    (var)->_current_locale = "C"; \
Line 466... Line 455...
466
  }
455
  }
467
 
456
 
468
/* Only built the assert() calls if we are built with debugging.  */
457
/* Only built the assert() calls if we are built with debugging.  */
Line 639... Line 628...
639
          unsigned char * _nextf[_N_LISTS];
628
          unsigned char * _nextf[_N_LISTS];
640
          unsigned int _nmalloc[_N_LISTS];
629
          unsigned int _nmalloc[_N_LISTS];
641
        } _unused;
630
        } _unused;
642
    } _new;
631
    } _new;
Line -... Line 632...
-
 
632
 
643
 
633
# ifndef _REENT_GLOBAL_ATEXIT
644
  /* atexit stuff */
634
  /* atexit stuff */
645
  struct _atexit *_atexit;	/* points to head of LIFO stack */
635
  struct _atexit *_atexit;	/* points to head of LIFO stack */
-
 
636
  struct _atexit _atexit0;	/* one guaranteed table, required by ANSI */
Line 646... Line 637...
646
  struct _atexit _atexit0;	/* one guaranteed table, required by ANSI */
637
# endif
647
 
638
 
Line 648... Line 639...
648
  /* signal info */
639
  /* signal info */
Line 696... Line 687...
696
        {0, {0}}, \
687
        {0, {0}}, \
697
        {0, {0}}, \
688
        {0, {0}}, \
698
        {0, {0}} \
689
        {0, {0}} \
699
      } \
690
      } \
700
    }, \
691
    }, \
701
    _NULL, \
692
    _REENT_INIT_ATEXIT \
702
    {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}, \
-
 
703
    _NULL, \
693
    _NULL, \
704
    {_NULL, 0, _NULL} \
694
    {_NULL, 0, _NULL} \
705
  }
695
  }
Line 706... Line 696...
706
 
696
 
707
#define _REENT_INIT_PTR(var) \
697
#define _REENT_INIT_PTR(var) \
708
  { (var)->_errno = 0; \
698
  { memset((var), 0, sizeof(*(var))); \
709
    (var)->_stdin = &(var)->__sf[0]; \
699
    (var)->_stdin = &(var)->__sf[0]; \
710
    (var)->_stdout = &(var)->__sf[1]; \
700
    (var)->_stdout = &(var)->__sf[1]; \
711
    (var)->_stderr = &(var)->__sf[2]; \
-
 
712
    (var)->_inc = 0; \
-
 
713
    memset(&(var)->_emergency, 0, sizeof((var)->_emergency)); \
-
 
714
    (var)->_current_category = 0; \
701
    (var)->_stderr = &(var)->__sf[2]; \
715
    (var)->_current_locale = "C"; \
-
 
716
    (var)->__sdidinit = 0; \
-
 
717
    (var)->__cleanup = _NULL; \
-
 
718
    (var)->_result = _NULL; \
-
 
719
    (var)->_result_k = 0; \
-
 
720
    (var)->_p5s = _NULL; \
-
 
721
    (var)->_freelist = _NULL; \
-
 
722
    (var)->_cvtlen = 0; \
-
 
723
    (var)->_cvtbuf = _NULL; \
-
 
724
    (var)->_new._reent._unused_rand = 0; \
-
 
725
    (var)->_new._reent._strtok_last = _NULL; \
-
 
726
    (var)->_new._reent._asctime_buf[0] = 0; \
-
 
727
    memset(&(var)->_new._reent._localtime_buf, 0, sizeof((var)->_new._reent._localtime_buf)); \
-
 
728
    (var)->_new._reent._gamma_signgam = 0; \
702
    (var)->_current_locale = "C"; \
729
    (var)->_new._reent._rand_next = 1; \
703
    (var)->_new._reent._rand_next = 1; \
730
    (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
704
    (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; \
731
    (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
705
    (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; \
732
    (var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \
706
    (var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; \
733
    (var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \
707
    (var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; \
734
    (var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
708
    (var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; \
735
    (var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
709
    (var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; \
736
    (var)->_new._reent._r48._add = _RAND48_ADD; \
-
 
737
    (var)->_new._reent._mblen_state.__count = 0; \
-
 
738
    (var)->_new._reent._mblen_state.__value.__wch = 0; \
-
 
739
    (var)->_new._reent._mbtowc_state.__count = 0; \
-
 
740
    (var)->_new._reent._mbtowc_state.__value.__wch = 0; \
-
 
741
    (var)->_new._reent._wctomb_state.__count = 0; \
-
 
742
    (var)->_new._reent._wctomb_state.__value.__wch = 0; \
-
 
743
    (var)->_new._reent._mbrlen_state.__count = 0; \
-
 
744
    (var)->_new._reent._mbrlen_state.__value.__wch = 0; \
-
 
745
    (var)->_new._reent._mbrtowc_state.__count = 0; \
-
 
746
    (var)->_new._reent._mbrtowc_state.__value.__wch = 0; \
-
 
747
    (var)->_new._reent._mbsrtowcs_state.__count = 0; \
-
 
748
    (var)->_new._reent._mbsrtowcs_state.__value.__wch = 0; \
-
 
749
    (var)->_new._reent._wcrtomb_state.__count = 0; \
-
 
750
    (var)->_new._reent._wcrtomb_state.__value.__wch = 0; \
-
 
751
    (var)->_new._reent._wcsrtombs_state.__count = 0; \
-
 
752
    (var)->_new._reent._wcsrtombs_state.__value.__wch = 0; \
-
 
753
    (var)->_new._reent._l64a_buf[0] = '\0'; \
-
 
754
    (var)->_new._reent._signal_buf[0] = '\0'; \
-
 
755
    (var)->_new._reent._getdate_err = 0; \
-
 
756
    (var)->_atexit = _NULL; \
-
 
757
    (var)->_atexit0._next = _NULL; \
-
 
758
    (var)->_atexit0._ind = 0; \
-
 
759
    (var)->_atexit0._fns[0] = _NULL; \
-
 
760
    (var)->_atexit0._on_exit_args._fntypes = 0; \
-
 
761
    (var)->_atexit0._on_exit_args._fnargs[0] = _NULL; \
-
 
762
    (var)->_sig_func = _NULL; \
-
 
763
    (var)->__sglue._next = _NULL; \
-
 
764
    (var)->__sglue._niobs = 0; \
-
 
765
    (var)->__sglue._iobs = _NULL; \
-
 
766
    memset(&(var)->__sf, 0, sizeof((var)->__sf)); \
710
    (var)->_new._reent._r48._add = _RAND48_ADD; \
Line 767... Line 711...
767
  }
711
  }
768
 
712
 
769
#define _REENT_CHECK_RAND48(ptr)	/* nothing */
713
#define _REENT_CHECK_RAND48(ptr)	/* nothing */
Line 820... Line 764...
820
 
764
 
Line 821... Line 765...
821
void _reclaim_reent _PARAMS ((struct _reent *));
765
void _reclaim_reent _PARAMS ((struct _reent *));
Line 822... Line -...
822
 
-
 
-
 
766
 
-
 
767
/* #define _REENT_ONLY define this to get only reentrant routines */
823
/* #define _REENT_ONLY define this to get only reentrant routines */
768
 
824
 
769
#if defined(__DYNAMIC_REENT__) && !defined(__SINGLE_THREAD__)
825
 
770
#ifndef __getreent
826
static inline struct _reent *__getreent(void)
771
static inline struct _reent *__getreent(void)
827
{
772
{
828
    struct _reent *ent;
773
    struct _reent *ent;
829
    __asm__ __volatile__(
774
    __asm__ __volatile__(
830
    "movl %%fs:16, %0"
775
    "movl %%fs:16, %0"
831
    :"=r"(ent));
776
    :"=r"(ent));
832
    return ent;
777
    return ent;
-
 
778
};
-
 
779
#endif
-
 
780
# define _REENT (__getreent())
-
 
781
#else /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
833
};
782
# define _REENT _impure_ptr
Line -... Line 783...
-
 
783
#endif /* __SINGLE_THREAD__ || !__DYNAMIC_REENT__ */
-
 
784
 
-
 
785
#define _GLOBAL_REENT _global_impure_ptr
-
 
786
 
-
 
787
#ifdef _REENT_GLOBAL_ATEXIT
-
 
788
extern struct _atexit *_global_atexit; /* points to head of LIFO stack */
-
 
789
# define _GLOBAL_ATEXIT _global_atexit
834
 
790
#else
835
# define _REENT (__getreent())
791
# define _GLOBAL_ATEXIT (_GLOBAL_REENT->_atexit)
836
#define _GLOBAL_REENT _global_impure_ptr
792
#endif
837
 
793