Branch data Line data Source code
1 : : // This file is a part of Julia. License is MIT: https://julialang.org/license 2 : : 3 : : #ifndef JL_SERIALIZE_H 4 : : #define JL_SERIALIZE_H 5 : : 6 : : #ifdef __cplusplus 7 : : extern "C" { 8 : : #endif 9 : : 10 : : #define TAG_SYMBOL 2 11 : : #define TAG_SSAVALUE 3 12 : : #define TAG_DATATYPE 4 13 : : #define TAG_SLOTNUMBER 5 14 : : #define TAG_SVEC 6 15 : : #define TAG_ARRAY 7 16 : : #define TAG_NULL 8 17 : : #define TAG_EXPR 9 18 : : #define TAG_PHINODE 10 19 : : #define TAG_PHICNODE 11 20 : : #define TAG_LONG_SYMBOL 12 21 : : #define TAG_LONG_SVEC 13 22 : : #define TAG_LONG_EXPR 14 23 : : #define TAG_LONG_PHINODE 15 24 : : #define TAG_LONG_PHICNODE 16 25 : : #define TAG_METHODROOT 17 26 : : #define TAG_STRING 18 27 : : #define TAG_SHORT_INT64 19 28 : : #define TAG_SHORT_GENERAL 20 29 : : #define TAG_CNULL 21 30 : : #define TAG_ARRAY1D 22 31 : : #define TAG_SINGLETON 23 32 : : #define TAG_MODULE 24 33 : : #define TAG_TVAR 25 34 : : #define TAG_METHOD_INSTANCE 26 35 : : #define TAG_METHOD 27 36 : : #define TAG_CODE_INSTANCE 28 37 : : #define TAG_COMMONSYM 29 38 : : #define TAG_NEARBYGLOBAL 30 39 : : #define TAG_GLOBALREF 31 40 : : #define TAG_CORE 32 41 : : #define TAG_BASE 33 42 : : #define TAG_BITYPENAME 34 43 : : #define TAG_NEARBYMODULE 35 44 : : #define TAG_INT32 36 45 : : #define TAG_INT64 37 46 : : #define TAG_UINT8 38 47 : : #define TAG_VECTORTY 39 48 : : #define TAG_PTRTY 40 49 : : #define TAG_LONG_SSAVALUE 41 50 : : #define TAG_LONG_METHODROOT 42 51 : : #define TAG_SHORTER_INT64 43 52 : : #define TAG_SHORT_INT32 44 53 : : #define TAG_CALL1 45 54 : : #define TAG_CALL2 46 55 : : #define TAG_LINEINFO 47 56 : : #define TAG_SHORT_BACKREF 48 57 : : #define TAG_BACKREF 49 58 : : #define TAG_UNIONALL 50 59 : : #define TAG_GOTONODE 51 60 : : #define TAG_QUOTENODE 52 61 : : #define TAG_GENERAL 53 62 : : #define TAG_GOTOIFNOT 54 63 : : #define TAG_RETURNNODE 55 64 : : #define TAG_ARGUMENT 56 65 : : #define TAG_RELOC_METHODROOT 57 66 : : 67 : : #define LAST_TAG 57 68 : : 69 : : #define write_uint8(s, n) ios_putc((n), (s)) 70 : : #define read_uint8(s) ((uint8_t)ios_getc((s))) 71 : : #define write_int8(s, n) write_uint8((s), (n)) 72 : : #define read_int8(s) read_uint8((s)) 73 : : 74 : : /* read and write in host byte order */ 75 : : 76 : 2314515 : static inline void write_int32(ios_t *s, int32_t i) JL_NOTSAFEPOINT 77 : : { 78 : 2314515 : ios_write(s, (char*)&i, 4); 79 : 2314515 : } 80 : : 81 : 15096705 : static inline int32_t read_int32(ios_t *s) JL_NOTSAFEPOINT 82 : : { 83 : 15096705 : int32_t x = 0; 84 : 15096705 : ios_read(s, (char*)&x, 4); 85 : 15096705 : return x; 86 : : } 87 : : 88 : 1793401 : static inline uint64_t read_uint64(ios_t *s) JL_NOTSAFEPOINT 89 : : { 90 : 1793401 : uint64_t x = 0; 91 : 1793401 : ios_read(s, (char*)&x, 8); 92 : 1793401 : return x; 93 : : } 94 : : 95 : 1402657 : static inline void write_int64(ios_t *s, int64_t i) JL_NOTSAFEPOINT 96 : : { 97 : 1402657 : ios_write(s, (char*)&i, 8); 98 : 1402657 : } 99 : : 100 : 560657949 : static inline void write_uint16(ios_t *s, uint16_t i) JL_NOTSAFEPOINT 101 : : { 102 : 560657949 : ios_write(s, (char*)&i, 2); 103 : 560657949 : } 104 : : 105 : 507843863 : static inline uint16_t read_uint16(ios_t *s) JL_NOTSAFEPOINT 106 : : { 107 : 507843863 : int16_t x = 0; 108 : 507843863 : ios_read(s, (char*)&x, 2); 109 : 507843863 : return x; 110 : : } 111 : : 112 : 10093280 : static inline void write_uint32(ios_t *s, uint32_t i) JL_NOTSAFEPOINT 113 : : { 114 : 10093280 : ios_write(s, (char*)&i, 4); 115 : 10093280 : } 116 : : 117 : 3397226 : static inline uint32_t read_uint32(ios_t *s) JL_NOTSAFEPOINT 118 : : { 119 : 3397226 : uint32_t x = 0; 120 : 3397226 : ios_read(s, (char*)&x, 4); 121 : 3397226 : return x; 122 : : } 123 : : 124 : : void *jl_lookup_ser_tag(jl_value_t *v); 125 : : void *jl_lookup_common_symbol(jl_value_t *v); 126 : : jl_value_t *jl_deser_tag(uint8_t tag); 127 : : jl_value_t *jl_deser_symbol(uint8_t tag); 128 : : 129 : : #ifdef __cplusplus 130 : : } 131 : : #endif 132 : : 133 : : #endif /* JL_SERIALIZE_H */