libk  Diff

Differences From Artifact [cb5067b74b]:

To Artifact [ded1289884]:


     1      1   #ifndef KIcore
     2      2   #define KIcore
     3      3   #include <k/type.h>
     4      4   #include <k/io.h>
     5      5   #include <k/str.h>
     6      6   
     7         -static void* const null = (void*)0;
     8         -
     9      7   typedef struct kvar {
    10      8   	ksraw name;
    11      9   	ksraw val;
    12     10   	char* platform;
    13     11   } kvar;
    14     12   
    15     13   typedef struct kenv {
    16     14   	kiochan std;
    17     15   	kiochan err;
    18     16   	sz argc; char** argv;
    19     17   	kvar* vars;
    20     18   } kenv;
    21     19   
           20  +
           21  +/* i'm really sorry okay */
           22  +typedef
           23  +#if (__STDC_VERSION__ >= 199901L)
           24  +	_Bool bool;
           25  +#endif
           26  +enum
           27  +#if !(__STDC_VERSION__ >= 199901L)
           28  +	bool /* enum bool { */
           29  +#endif
           30  +{
           31  +	false = 0, no  = 0,
           32  +	true  = 1, yes = 1
           33  +}
           34  +#if !(__STDC_VERSION__ >= 199901L)
           35  +	bool /* } bool ; */
           36  +#endif
           37  +;
           38  +
           39  +#ifndef KFclean
           40  +#	if (__STDC_VERSION__ >= 199901L) ||\
           41  +	   (__cplusplus      >= 201103L)
           42  +#		define KVvm_args __VA_ARGS__
           43  +#		define KVvm_spec ...
           44  +#		define KFfeat_variadic_macro
           45  +#	else
           46  +#		define KVvm_args K_TEMP_M2QD52
           47  +#		define KVvm_spec K_TEMP_M2QD52
           48  +#	endif
           49  +#	if defined(__GNUC__) || defined(__clang__)
           50  +#		define KA(KVvm_spec) __attribute__((KVvm_args))
           51  +#	else
           52  +#		define KA(KVvm_spec)
           53  +#	endif
           54  +#	define KAformat(KVvm_spec) KA(format(KVvm_args))
           55  +#	define KAexport(KVvm_spec) KA(visibility(KVvm_args))
           56  +
           57  +#	define KAunused   KA(unused)
           58  +#	define KAnoreturn KA(noreturn)
           59  +#	define KApure     KA(const)
           60  +#	define KAinline   KA(always_inline)
           61  +#	define KAflatten  KA(flatten)
           62  +#	define KAexport_none  KAexport("hidden")
           63  +#	define KAexport_force KAexport("default")
           64  +/*  now we define standard version flags,
           65  + *  to make it easy for the user to write
           66  + *  more portable code. */
           67  +#	if (__STDC_VERSION__ >= 199901L) 
           68  +#		define KFstd_c89
           69  +#		define KFstd_c99
           70  +#		define KVstd c99
           71  +#	else
           72  +#		ifdef __STDC__
           73  +#			define KFstd_c89
           74  +#			define KVstd c89
           75  +#		else
           76  +#			define KVstd K&R /* UH OH */
           77  +#		endif
           78  +#	endif
           79  +#	if (__STDC_VERSION__ >= 201103L)
           80  +#		define KFstd_c11
           81  +#		define KVstd c11
           82  +#	endif
           83  +#	ifdef __cplusplus
           84  +#		define KFstd_cpp
           85  +#		define KVstd c++
           86  +#		if (__cplusplus >= 201103L)
           87  +#			define KFstd_cpp11
           88  +#			define KVstd c++11
           89  +#		endif /* TODO: add more */
           90  +#	endif
           91  +#endif
           92  +
           93  +/* hooo boy. null. that one's got a storied
           94  + * history across the versions and dialects.
           95  + * below, we try to find the ideal way to
           96  + * offer a "null" "keyword" depending on
           97  + * dialect, version, and whether the user
           98  + * has asked for macros to be suspended.
           99  + * note that this may result in no "null"
          100  + * being defined in C++ or K&R C. */
          101  +#if defined (__cplusplus) && ! defined(KFclean)
          102  +#	if __cplusplus >= 201103L
          103  +#		define null nullptr
          104  +#	else
          105  +#		define null ((void*)0)
          106  +#	endif
          107  +#elif defined __STDC__
          108  +	enum { null = 0 };
          109  +	/* believe it or not, this is actually
          110  +	 * completely legal. doesn't even raise
          111  +	 * a single warning. i was surprised too. */
          112  +#elif ! defined(KFclean)
          113  +#	define null ((void*)0)
          114  +#endif
          115  +
          116  +#ifdef __cplusplus
          117  +#	define noreturn [[ noreturn ]]
          118  +#elif __STDC_VERSION__ >= 201103L
          119  +#	define noreturn _Noreturn
          120  +#else
          121  +#	define noreturn
          122  +#endif
          123  +
          124  +noreturn void kstop(longstat code);
          125  +
          126  +#ifdef KFclean
          127  +#	undef noreturn
          128  +#endif
          129  +
    22    130   #endif