erwin/base.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #ifdef ERWIN_DEBUG_INCLUDE
51 #warning "Including base.h."
52 #endif
53
54 #ifndef Global_ERWIN_BASE_H
55 #define Global_ERWIN_BASE_H
56
57 #ifdef ERWIN_DEBUG_INCLUDE
58 #warning "First inclusion of base.h."
59 #endif
60
61 #ifdef Global_ERWIN_COMPILING
62 # include "--INCPREF2B--erwin/defs.h"
63 # include "--INCPREF2B--erwin/map.h"
64 # include "--INCPREF2B--erwin/vector.h"
65 # include "--INCPREF2B--erwin/list.h"
66 # include "--INCPREF2B--erwin/typeinfo.h"
67 #else
68 # include <--INCPREF2B--erwin/defs.h>
69 # include <--INCPREF2B--erwin/map.h>
70 # include <--INCPREF2B--erwin/vector.h>
71 # include <--INCPREF2B--erwin/list.h>
72 # include <--INCPREF2B--erwin/typeinfo.h>
73 #endif
74
75 #ifdef Global_ERWIN_ADAM_NAME
76
77 #COPYDEF ERWIN_MAJOR_VERSION
78 #COPYDEF ERWIN_MINOR_VERSION
79 #COPYDEF ERWIN_MICRO_VERSION
80 #COPYDEF ERWIN_VERSION_CODE
81
82 #COPYNAME initializer_t
83 #COPYNAME erwin_strtoul
84 #COPYNAME erwin_strtol
85 #COPYNAME erwin_strtoull
86 #COPYNAME erwin_strtoll
87 #COPYNAME erwin_strntoul
88 #COPYNAME erwin_strntol
89 #COPYNAME erwin_strntoull
90 #COPYNAME erwin_strntoll
91 #COPYNAME string_free
92 #COPYNAME string_cmp
93 #COPYNAME string_equ
94 #COPYNAME string_case_cmp
95 #COPYNAME string_case_equ
96 #COPYNAME string_dup
97 #COPYNAME string_length
98 #COPYNAME char_is_alpha
99 #COPYNAME char_is_lower
100 #COPYNAME char_is_upper
101 #COPYNAME char_is_digit
102 #COPYNAME char_is_xdigit
103 #COPYNAME char_is_space
104 #COPYNAME char_is_space0
105 #COPYNAME char_is_cr
106 #COPYNAME char_is_cr0
107 #COPYNAME erwin_merge_sort
108 #COPYNAME erwin_register_init
109 #COPYNAME erwin_version
110 #COPYNAME erwin_package_date
111 #COPYNAME erwin_assertion_is_fatal
112 #COPYNAME erwin_install_date
113 #COPYNAME erwin_init_date
114 #COPYNAME erwin_version_1
115 #COPYNAME erwin_version_2
116 #COPYNAME erwin_set_determinism
117 #COPYNAME erwin_require_determinism
118 #COPYNAME erwin_det_random
119
120 #else
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169 #ifndef erwin_nonnegative
170
171 #ifdef __cplusplus
172
173 #define erwin_nonnegative erwin_nonnegative
174
175 ERWIN_WRAPPER bool erwin_nonnegative (char) ATTR_CONST;
176 ERWIN_WRAPPER bool erwin_nonnegative (char x)
177 {
178 #ifdef __CHAR_UNSIGNED__
179 return true;
180 #else
181 return x >= 0;
182 #endif
183 }
184
185 ERWIN_WRAPPER bool erwin_nonnegative (signed char) ATTR_CONST;
186 ERWIN_WRAPPER bool erwin_nonnegative (signed char x)
187 {
188 return x >= 0;
189 }
190
191 ERWIN_WRAPPER bool erwin_nonnegative (signed short) ATTR_CONST;
192 ERWIN_WRAPPER bool erwin_nonnegative (signed short x)
193 {
194 return x >= 0;
195 }
196
197 ERWIN_WRAPPER bool erwin_nonnegative (signed int) ATTR_CONST;
198 ERWIN_WRAPPER bool erwin_nonnegative (signed int x)
199 {
200 return x >= 0;
201 }
202
203 ERWIN_WRAPPER bool erwin_nonnegative (signed long) ATTR_CONST;
204 ERWIN_WRAPPER bool erwin_nonnegative (signed long x)
205 {
206 return x >= 0;
207 }
208
209 #ifdef ERWIN_LONG_LONG
210 ERWIN_WRAPPER bool erwin_nonnegative (ERWIN_LONG_LONG) ATTR_CONST;
211 ERWIN_WRAPPER bool erwin_nonnegative (ERWIN_LONG_LONG x)
212 {
213 return x >= 0;
214 }
215 #endif
216
217 ERWIN_WRAPPER bool erwin_nonnegative (float) ATTR_CONST;
218 ERWIN_WRAPPER bool erwin_nonnegative (float x)
219 {
220 return x >= 0;
221 }
222
223 ERWIN_WRAPPER bool erwin_nonnegative (double) ATTR_CONST;
224 ERWIN_WRAPPER bool erwin_nonnegative (double x)
225 {
226 return x >= 0;
227 }
228
229 #if SIZEOF_LONG_DOUBLE > 0
230 ERWIN_WRAPPER bool erwin_nonnegative (long double) ATTR_CONST;
231 ERWIN_WRAPPER bool erwin_nonnegative (long double x)
232 {
233 return x >= 0;
234 }
235 #endif
236
237 ERWIN_WRAPPER bool erwin_nonnegative (bool) ATTR_CONST;
238 ERWIN_WRAPPER bool erwin_nonnegative (bool)
239 {
240 return true;
241 }
242
243 ERWIN_WRAPPER bool erwin_nonnegative (unsigned char) ATTR_CONST;
244 ERWIN_WRAPPER bool erwin_nonnegative (unsigned char)
245 {
246 return true;
247 }
248
249 ERWIN_WRAPPER bool erwin_nonnegative (unsigned short) ATTR_CONST;
250 ERWIN_WRAPPER bool erwin_nonnegative (unsigned short)
251 {
252 return true;
253 }
254
255 ERWIN_WRAPPER bool erwin_nonnegative (unsigned int) ATTR_CONST;
256 ERWIN_WRAPPER bool erwin_nonnegative (unsigned int)
257 {
258 return true;
259 }
260
261 ERWIN_WRAPPER bool erwin_nonnegative (unsigned long) ATTR_CONST;
262 ERWIN_WRAPPER bool erwin_nonnegative (unsigned long)
263 {
264 return true;
265 }
266
267 #ifdef ERWIN_UNSIGNED_LONG_LONG
268 ERWIN_WRAPPER bool erwin_nonnegative (ERWIN_UNSIGNED_LONG_LONG) ATTR_CONST;
269 ERWIN_WRAPPER bool erwin_nonnegative (ERWIN_UNSIGNED_LONG_LONG)
270 {
271 return true;
272 }
273 #endif
274
275 #else
276
277
278 #if Global_ERWIN_OPTIMISE
279 # define erwin_nonnegative(x) ((x) >= 0)
280 #else
281 # define erwin_nonnegative(x) (((int)((x) >> (sizeof(x)*8-1))) >= 0)
282 #endif
283
284 #endif
285
286 #endif
287
288
289 #ifdef __cplusplus
290 extern "C" {
291 #endif
292
293
294
295 typedef void (*Global_initializer_t) (int *, char ***);
296
297
298 #define Global_SO_NO_UNDERBAR 0x80
299 #define Global_SO_NO_BINARY 0x100
300 #define Global_SO_BASE_MASK 0x7f
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 extern unsigned long Global_erwin_strtoul (
326 char const * ,
327 char ** ERWIN_DEFAULT_ARG (NULL),
328 int ERWIN_DEFAULT_ARG(0));
329
330 extern long Global_erwin_strtol (
331 char const * ,
332 char ** ERWIN_DEFAULT_ARG (NULL),
333 int ERWIN_DEFAULT_ARG(0));
334
335 #ifdef ERWIN_LONG_LONG
336
337 extern ERWIN_UNSIGNED_LONG_LONG Global_erwin_strtoull (
338 char const * ,
339 char ** ERWIN_DEFAULT_ARG (NULL),
340 int ERWIN_DEFAULT_ARG(0));
341
342 extern ERWIN_LONG_LONG Global_erwin_strtoll (
343 char const * ,
344 char ** ERWIN_DEFAULT_ARG (NULL),
345 int ERWIN_DEFAULT_ARG(0));
346
347 #endif
348
349 extern unsigned long Global_erwin_strntoul (
350 char const * ,
351 size_t ,
352 char ** ERWIN_DEFAULT_ARG (NULL),
353 int ERWIN_DEFAULT_ARG(0));
354
355 extern long Global_erwin_strntol (
356 char const * ,
357 size_t ,
358 char ** ERWIN_DEFAULT_ARG (NULL),
359 int ERWIN_DEFAULT_ARG(0));
360
361 #ifdef ERWIN_LONG_LONG
362
363 extern ERWIN_UNSIGNED_LONG_LONG Global_erwin_strntoull (
364 char const * ,
365 size_t ,
366 char ** ERWIN_DEFAULT_ARG (NULL),
367 int ERWIN_DEFAULT_ARG(0));
368
369 extern ERWIN_LONG_LONG Global_erwin_strntoll (
370 char const * ,
371 size_t ,
372 char ** ERWIN_DEFAULT_ARG (NULL),
373 int ERWIN_DEFAULT_ARG(0));
374
375 #endif
376
377
378
379
380
381
382
383
384 extern void Global_string_free (char * );
385
386
387
388
389
390
391
392
393
394
395
396 extern int Global_string_cmp (char const * , char const * ) ATTR_PURE;
397
398
399
400
401
402
403
404
405
406 extern int Global_memory_cmp (void const * , void const * , size_t ) ATTR_PURE;
407
408
409
410
411
412
413
414
415
416 extern int Global_string_n_cmp (char const * , char const * , size_t ) ATTR_PURE;
417
418
419
420
421
422
423
424
425 extern char *Global_string_string (char const * , char const * ) ATTR_PURE;
426
427
428
429
430
431 extern char *Global_string_n_string (
432 char const * , char const * , size_t) ATTR_PURE;
433
434
435
436
437
438 extern void *Global_memory_memory (
439 void const * , size_t ,
440 void const * , size_t ) ATTR_PURE;
441
442
443
444
445
446
447
448
449
450
451 extern int Global_string_case_cmp (char const * , char const * ) ATTR_PURE;
452
453
454
455
456
457 extern int Global_string_n_case_cmp (char const * , char const * , size_t )
458 ATTR_PURE;
459
460
461
462
463
464 extern char *Global_string_case_string (char const * , char const * )
465 ATTR_PURE;
466
467
468
469
470
471 extern char *Global_string_n_case_string (
472 char const * , char const * , size_t) ATTR_PURE;
473
474
475
476
477
478
479
480
481 extern char *Global_string_dup (
482 char const * , int * ERWIN_DEFAULT_ARG((int*)NULL))
483 ATTR_MALLOC;
484
485
486
487
488
489
490
491
492
493
494
495 extern char *Global_string_n_dup (
496 char const * , size_t , int * ERWIN_DEFAULT_ARG((int*)NULL))
497 ATTR_MALLOC;
498
499
500
501
502
503 extern void *Global_erwin_memset0 (
504 void * , size_t , size_t );
505
506
507
508
509
510
511
512
513
514 extern size_t Global_string_length (char const *) ATTR_PURE;
515
516
517
518
519
520 extern size_t Global_string_n_length (char const *, size_t) ATTR_PURE;
521
522
523
524
525
526 extern int Global_erwin_digit_value (char) ATTR_CONST;
527
528
529
530
531
532
533
534 extern char Global_erwin_get_digit (int ) ATTR_CONST;
535
536
537
538
539 extern char Global_erwin_get_digit_upper (int ) ATTR_CONST;
540
541
542
543
544
545
546
547 #define Global_erwin_strcmp Global_string_cmp
548 #define Global_erwin_memcmp Global_memory_cmp
549 #define Global_erwin_strncmp Global_string_n_cmp
550 #define Global_erwin_strlen Global_string_length
551 #define Global_erwin_strnlen Global_string_n_length
552
553
554 #define Global_erwin_strdup(A) Global_string_dup((A), NULL)
555
556
557 #define Global_erwin_strcasecmp Global_string_case_cmp
558 #define Global_erwin_strncasecmp Global_string_n_case_cmp
559 #define Global_erwin_strstr Global_string_string
560 #define Global_erwin_memmem Global_memory_memory
561 #define Global_erwin_strcasestr Global_string_case_string
562 #define Global_erwin_strnstr Global_string_n_string
563 #define Global_erwin_strncasestr Global_string_n_case_string
564
565
566 #define Global_erwin_stricmp Global_string_case_cmp
567 #define Global_erwin_strnicmp Global_string_n_case_cmp
568 #define Global_erwin_stristr Global_string_case_string
569 #define Global_erwin_strnistr Global_string_n_case_string
570
571
572 #define Global_erwin_strfree Global_string_free
573 #define Global_erwin_strndup Global_string_n_dup
574
575 #define Global_erwin_memequ(A,B,C) (Global_memory_cmp(A,B,C) == 0)
576 #define Global_erwin_strequ(A,B) (Global_string_cmp(A,B) == 0)
577 #define Global_erwin_strcaseequ(A,B) (Global_string_case_cmp(A,B) == 0)
578 #define Global_erwin_strnequ(A,B,N) (Global_string_n_cmp(A,B,N) == 0)
579 #define Global_erwin_strncaseequ(A,B,N) (Global_string_n_case_cmp(A,B,N) == 0)
580
581 #define Global_string_equ(A,B) (Global_string_cmp(A,B) == 0)
582 #define Global_string_case_equ(A,B) (Global_string_case_cmp(A,B) == 0)
583 #define Global_string_n_equ(A,B,N) (Global_string_n_cmp(A,B,N) == 0)
584 #define Global_string_n_case_equ(A,B,N) (Global_string_n_case_cmp(A,B,N) == 0)
585
586 extern Global_ERWIN_BOOL Global_string_is_prefix (
587 int * , char const * , char const * );
588
589 extern Global_ERWIN_BOOL Global_string_is_suffix (
590 int * , char const * , char const * );
591
592 extern char const *Global_erwin_strsignal (int);
593
594
595
596
597
598
599 extern Global_ERWIN_BOOL Global_char_is_alpha (char) ATTR_CONST;
600 extern Global_ERWIN_BOOL Global_char_is_lower (char) ATTR_CONST;
601 extern Global_ERWIN_BOOL Global_char_is_upper (char) ATTR_CONST;
602 extern Global_ERWIN_BOOL Global_char_is_digit (char) ATTR_CONST;
603 extern Global_ERWIN_BOOL Global_char_is_xdigit (char) ATTR_CONST;
604 extern Global_ERWIN_BOOL Global_char_is_space (char) ATTR_CONST;
605 extern Global_ERWIN_BOOL Global_char_is_space0 (char) ATTR_CONST;
606 extern Global_ERWIN_BOOL Global_char_is_cr (char) ATTR_CONST;
607 extern Global_ERWIN_BOOL Global_char_is_cr0 (char) ATTR_CONST;
608
609
610 #define Global_erwin_isalpha Global_char_is_alpha
611 #define Global_erwin_islower Global_char_is_lower
612 #define Global_erwin_isupper Global_char_is_upper
613 #define Global_erwin_isdigit Global_char_is_digit
614 #define Global_erwin_isxdigit Global_char_is_xdigit
615 #define Global_erwin_isspace Global_char_is_space
616
617 #define Global_erwin_isspace0 Global_char_is_space0
618 #define Global_erwin_iscr Global_char_is_cr
619 #define Global_erwin_iscr0 Global_char_is_cr0
620
621
622 ERWIN_WRAPPER Global_hashval_t Global_string_hash (char const *) ATTR_PURE;
623 ERWIN_WRAPPER Global_hashval_t Global_string_hash (char const *c)
624 {
625 return Global_erwin_u8_array_hash ((ERWIN_U8*)c, Global_string_length(c));
626 }
627
628 ERWIN_WRAPPER Global_hashval_t Global_string_case_hash (char const *) ATTR_PURE;
629 ERWIN_WRAPPER Global_hashval_t Global_string_case_hash (char const *c)
630 {
631 return Global_erwin_u8_array_case_hash ((ERWIN_U8*)c, Global_string_length(c));
632 }
633
634 typedef int (* Global_erwin_comparison_t) (void const *, void const *);
635
636 void Global_erwin_merge_sort (
637 void *abase,
638 size_t anmemb,
639 size_t asize,
640 Global_erwin_comparison_t );
641
642
643
644
645
646
647
648
649
650
651 extern void Global_erwin_init (int * , char *** );
652
653 extern int Global_erwin_register_init (Global_initializer_t);
654
655
656
657
658
659
660
661
662
663
664
665
666 #define Global_ERWIN_MAJOR_VERSION --MAJOR-VERSION--
667 #define Global_ERWIN_MINOR_VERSION --MINOR-VERSION--
668 #define Global_ERWIN_MICRO_VERSION --MICRO-VERSION--
669 #define Global_ERWIN_VERSION_CODE Global_ERWIN_VERSION(Global_ERWIN_MAJOR_VERSION,Global_ERWIN_MINOR_VERSION,Global_ERWIN_MICRO_VERSION)
670
671
672
673
674
675
676
677 extern char const *const Global_erwin_version;
678 extern char const *const Global_erwin_package_date;
679
680
681 extern Global_ERWIN_BOOL Global_erwin_assertion_is_fatal;
682
683
684 extern char const *const Global_erwin_install_date;
685
686
687 extern char const *const Global_erwin_init_date;
688
689
690 extern int const Global_erwin_version_1;
691 extern int const Global_erwin_version_2;
692
693
694 #ifdef Global_ERWIN_REQUIRE_DETERMINISM
695
696 extern void Global_erwin_set_determinism (Global_ERWIN_BOOL);
697
698
699
700
701
702
703 extern Global_ERWIN_BOOL Global_erwin_require_determinism (void);
704
705
706 #endif
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736 #ifdef Global_ERWIN_NEED_DET_RANDOM
737 extern unsigned long Global_erwin_det_random (void);
738
739
740
741
742 #endif
743
744 #ifdef __cplusplus
745 }
746 #endif
747
748 #endif
749
750 --INCLUDE-FORWARDS-LATE--
751
752 #endif