Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -1314,11 +1314,16 @@ extern void objc_autoreleasePoolPop(void *_Null_unspecified pool); #endif extern id of_alloc_object(Class class_, size_t extraSize, size_t extraAlignment, void *_Nullable *_Nullable extra); extern void OF_NO_RETURN_FUNC of_method_not_found(id self, SEL _cmd); +#ifndef OF_AMIGAOS extern uint32_t of_hash_seed; +#else +extern uint32_t *_Nonnull of_hash_seed_ref(void); +# define of_hash_seed (*of_hash_seed_ref()) +#endif #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -99,12 +99,24 @@ #define PRE_MEM(mem) ((struct pre_mem *)(void *)((char *)mem - PRE_MEM_ALIGN)) static struct { Class isa; } allocFailedException; + +#ifdef OF_AMIGAOS +# undef of_hash_seed +#endif uint32_t of_hash_seed; + +#ifdef OF_AMIGAOS +uint32_t * +of_hash_seed_ref(void) +{ + return &of_hash_seed; +} +#endif static const char * typeEncodingForSelector(Class class, SEL selector) { Method method; Index: src/amiga-glue.m ================================================================== --- src/amiga-glue.m +++ src/amiga-glue.m @@ -19,14 +19,17 @@ #import "OFApplication.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" #import "OFMethodSignature.h" +#import "OFObject.h" #import "OFStdIOStream.h" +#import "OFString.h" #import "OFZIPArchiveEntry.h" #import "amiga-library.h" +#import "of_strptime.h" #import "pbkdf2.h" #import "platform.h" #import "scrypt.h" #import "socket.h" @@ -108,10 +111,16 @@ { M68K_ARG(const char *, type, a0) return of_alignof_type_encoding(type); } + +uint32_t *__saveds +glue_of_hash_seed_ref(void) +{ + return of_hash_seed_ref(); +} OFStdIOStream **__saveds glue_of_stdin_ref(void) { return of_stdin_ref(); @@ -135,10 +144,62 @@ M68K_ARG(OFConstantString *, format, a0) M68K_ARG(va_list, arguments, a1) of_logv(format, arguments); } + +of_string_encoding_t __saveds +glue_of_string_parse_encoding PPC_PARAMS(OFString *string) +{ + M68K_ARG(OFString *, string, a0) + + return of_string_parse_encoding(string); +} + +OFString *__saveds +glue_of_string_name_of_encoding PPC_PARAMS(of_string_encoding_t encoding) +{ + M68K_ARG(of_string_encoding_t, encoding, d0) + + return of_string_name_of_encoding(encoding); +} + +size_t __saveds +glue_of_string_utf8_encode PPC_PARAMS(of_unichar_t c, char *UTF8) +{ + M68K_ARG(of_unichar_t, c, d0) + M68K_ARG(char *, UTF8, a0) + + return of_string_utf8_encode(c, UTF8); +} + +ssize_t __saveds +glue_of_string_utf8_decode PPC_PARAMS(const char *UTF8, size_t len, + of_unichar_t *c) +{ + M68K_ARG(const char *, UTF8, a0) + M68K_ARG(size_t, len, d0) + M68K_ARG(of_unichar_t *, c, a1) + + return of_string_utf8_decode(UTF8, len, c); +} + +size_t __saveds +glue_of_string_utf16_length PPC_PARAMS(const of_char16_t *string) +{ + M68K_ARG(const of_char16_t *, string, a0) + + return of_string_utf16_length(string); +} + +size_t __saveds +glue_of_string_utf32_length PPC_PARAMS(const of_char32_t *string) +{ + M68K_ARG(const of_char32_t *, string, a0) + + return of_string_utf32_length(string); +} OFString *__saveds glue_of_zip_archive_entry_version_to_string PPC_PARAMS(uint16_t version) { M68K_ARG(uint16_t, version, d0) @@ -184,10 +245,41 @@ M68K_ARG(bool, allowsSwappableMemory, d4) of_pbkdf2(HMAC, iterations, salt, saltLength, password, passwordLength, key, keyLength, allowsSwappableMemory); } + +void __saveds +glue_of_salsa20_8_core PPC_PARAMS(uint32_t *buffer) +{ + M68K_ARG(uint32_t *, buffer, a0) + + of_salsa20_8_core(buffer); +} + +void __saveds +glue_of_scrypt_block_mix PPC_PARAMS(uint32_t *output, const uint32_t *input, + size_t blockSize) +{ + M68K_ARG(uint32_t *, output, a0) + M68K_ARG(const uint32_t *, input, a1) + M68K_ARG(size_t, blockSize, d0) + + of_scrypt_block_mix(output, input, blockSize); +} + +void __saveds +glue_of_scrypt_romix PPC_PARAMS(uint32_t *buffer, size_t blockSize, + size_t costFactor, uint32_t *tmp) +{ + M68K_ARG(uint32_t *, buffer, a0) + M68K_ARG(size_t, blockSize, d0) + M68K_ARG(size_t, costFactor, d1) + M68K_ARG(uint32_t *, tmp, a1) + + of_scrypt_romix(buffer, blockSize, costFactor, tmp); +} void __saveds glue_of_scrypt PPC_PARAMS(size_t blockSize, size_t costFactor, size_t parallelization, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, @@ -205,10 +297,22 @@ M68K_ARG(bool, allowsSwappableMemory, d6) of_scrypt(blockSize, costFactor, parallelization, salt, saltLength, password, passwordLength, key, keyLength, allowsSwappableMemory); } + +const char *__saveds +glue_of_strptime PPC_PARAMS(const char *buf, const char *fmt, struct tm *tm, + int16_t *tz) +{ + M68K_ARG(const char *, buf, a0) + M68K_ARG(const char *, fmt, a1) + M68K_ARG(struct tm *, tm, a2) + M68K_ARG(int16_t *, tz, a3) + + return of_strptime(buf, fmt, tm, tz); +} void __saveds glue_of_socket_address_parse_ip PPC_PARAMS(of_socket_address_t *address, OFString *IP, uint16_t port) { Index: src/amiga-library.m ================================================================== --- src/amiga-library.m +++ src/amiga-library.m @@ -74,19 +74,30 @@ extern const char *glue_of_http_request_method_to_string(void); extern of_http_request_method_t glue_of_http_request_method_from_string(void); extern OFString *glue_of_http_status_code_to_string(void); extern size_t glue_of_sizeof_type_encoding(void); extern size_t glue_of_alignof_type_encoding(void); +extern uint32_t *glue_of_hash_seed_ref(void); extern OFStdIOStream **glue_of_stdin_ref(void); extern OFStdIOStream **glue_of_stdout_ref(void); extern OFStdIOStream **glue_of_stderr_ref(void); extern void glue_of_logv(void); +extern of_string_encoding_t glue_of_string_parse_encoding(void); +extern OFString *glue_of_string_name_of_encoding(void); +extern size_t glue_of_string_utf8_encode(void); +extern ssize_t glue_of_string_utf8_decode(void); +extern size_t glue_of_string_utf16_length(void); +extern size_t glue_of_string_utf32_length(void); extern OFString *glue_of_zip_archive_entry_version_to_string(void); extern OFString *glue_of_zip_archive_entry_compression_method_to_string(void); extern size_t glue_of_zip_archive_entry_extra_field_find(void); extern void glue_of_pbkdf2(void); +extern void glue_of_salsa20_8_core(void); +extern void glue_of_scrypt_block_mix(void); +extern void glue_of_scrypt_romix(void); extern void glue_of_scrypt(void); +extern const char *glue_of_strptime(void); extern of_socket_address_t glue_of_socket_address_parse_ip(void); extern of_socket_address_t glue_of_socket_address_parse_ipv4(void); extern of_socket_address_t glue_of_socket_address_parse_ipv6(void); extern of_socket_address_t glue_of_socket_address_ipx(void); extern bool glue_of_socket_address_equal(void); @@ -620,19 +631,30 @@ (CONST_APTR)glue_of_http_request_method_to_string, (CONST_APTR)glue_of_http_request_method_from_string, (CONST_APTR)glue_of_http_status_code_to_string, (CONST_APTR)glue_of_sizeof_type_encoding, (CONST_APTR)glue_of_alignof_type_encoding, + (CONST_APTR)of_hash_seed_ref, (CONST_APTR)glue_of_stdin_ref, (CONST_APTR)glue_of_stdout_ref, (CONST_APTR)glue_of_stderr_ref, (CONST_APTR)glue_of_logv, + (CONST_APTR)glue_of_string_parse_encoding, + (CONST_APTR)glue_of_string_name_of_encoding, + (CONST_APTR)glue_of_string_utf8_encode, + (CONST_APTR)glue_of_string_utf8_decode, + (CONST_APTR)glue_of_string_utf16_length, + (CONST_APTR)glue_of_string_utf32_length, (CONST_APTR)glue_of_zip_archive_entry_version_to_string, (CONST_APTR)glue_of_zip_archive_entry_compression_method_to_string, (CONST_APTR)glue_of_zip_archive_entry_extra_field_find, (CONST_APTR)glue_of_pbkdf2, + (CONST_APTR)glue_of_salsa20_8_core, + (CONST_APTR)glue_of_scrypt_block_mix, + (CONST_APTR)glue_of_scrypt_romix, (CONST_APTR)glue_of_scrypt, + (CONST_APTR)glue_of_strptime, (CONST_APTR)glue_of_socket_address_parse_ip, (CONST_APTR)glue_of_socket_address_parse_ipv4, (CONST_APTR)glue_of_socket_address_parse_ipv6, (CONST_APTR)glue_of_socket_address_ipx, (CONST_APTR)glue_of_socket_address_equal, Index: src/amigaos3.sfd ================================================================== --- src/amigaos3.sfd +++ src/amigaos3.sfd @@ -9,19 +9,30 @@ const char *_Nullable glue_of_http_request_method_to_string(of_http_request_method_t method)(d0) of_http_request_method_t glue_of_http_request_method_from_string(OFString *string)(a0) OFString *_Nonnull glue_of_http_status_code_to_string(short code)(d0) size_t glue_of_sizeof_type_encoding(const char *type)(a0) size_t glue_of_alignof_type_encoding(const char *type)(a0) +uint32_t *_Nonnull glue_of_hash_seed_ref(void)() OFStdIOStream *_Nonnull *_Nullable glue_of_stdin_ref(void)() OFStdIOStream *_Nonnull *_Nullable glue_of_stdout_ref(void)() OFStdIOStream *_Nonnull *_Nullable glue_of_stderr_ref(void)() void glue_of_logv(OFConstantString *format, va_list arguments)(a0,a1) +of_string_encoding_t glue_of_string_parse_encoding(OFString *string)(a0) +OFString *_Nullable glue_of_string_name_of_encoding(of_string_encoding_t encoding)(d0) +size_t glue_of_string_utf8_encode(of_unichar_t c, char *UTF8)(d0,a0) +ssize_t glue_of_string_utf8_decode(const char *UTF8, size_t len, of_unichar_t *c)(a0,d0,a1) +size_t glue_of_string_utf16_length(const of_char16_t *string)(a0) +size_t glue_of_string_utf32_length(const of_char32_t *string)(a0) OFString *_Nonnull glue_of_zip_archive_entry_version_to_string(uint16_t version)(d0) OFString *_Nonnull glue_of_zip_archive_entry_compression_method_to_string(uint16_t compressionMethod)(d0) size_t glue_of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag, uint16_t *size)(a0,d0,a1) void glue_of_pbkdf2(OFHMAC *HMAC, size_t iterations, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, size_t keyLength, bool allowsSwappableMemory)(a0,d0,a1,d1,a2,d2,a3,d3,d4) +void glue_of_salsa20_8_core(uint32_t *_Nonnull buffer)(a0) +void glue_of_scrypt_block_mix(uint32_t *_Nonnull output, const uint32_t *_Nonnull input, size_t blockSize)(a0,a1,d0) +void glue_of_scrypt_romix(uint32_t *buffer, size_t blockSize, size_t costFactor, uint32_t *tmp)(a0,d0,d1,a1) void glue_of_scrypt(size_t blockSize, size_t costFactor, size_t parallelization, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, size_t keyLength, bool allowsSwappableMemory)(d0,d1,d2,a0,d3,a1,d4,a2,d5,d6) +const char *_Nullable glue_of_strptime(const char *buf, const char *fmt, struct tm *tm, int16_t *_Nullable tz)(a0,a1,a2,a3) void glue_of_socket_address_parse_ip(of_socket_address_t *_Nonnull address, OFString *IP, uint16_t port)(a0,a1,d0) void glue_of_socket_address_parse_ipv4(of_socket_address_t *_Nonnull address, OFString *IP, uint16_t port)(a0,a1,d0) void glue_of_socket_address_parse_ipv6(of_socket_address_t *_Nonnull address, OFString *IP, uint16_t port)(a0,a1,d0) void glue_of_socket_address_ipx(of_socket_address_t *_Nonnull address, const unsigned char *_Nonnull node, uint32_t network, uint16_t port)(a0,a1,d0,d1) bool glue_of_socket_address_equal(const of_socket_address_t *_Nonnull address1, const of_socket_address_t *_Nonnull address2)(a0,a1) Index: src/linklib/linklib.m ================================================================== --- src/linklib/linklib.m +++ src/linklib/linklib.m @@ -262,10 +262,18 @@ void *__objc_class_name_OFThreadStartFailedException; void *__objc_class_name_OFThreadStillRunningException; #endif #include "OFFileManager_constants.m" #include "OFRunLoop_constants.m" +/* The following __objc_class_name_* are only required for the tests. */ +void *__objc_class_name_OFBitSetCharacterSet; +void *__objc_class_name_OFMapTableSet; +void *__objc_class_name_OFMutableMapTableSet; +void *__objc_class_name_OFMutableUTF8String; +void *__objc_class_name_OFRangeCharacterSet; +void *__objc_class_name_OFSelectKernelEventObserver; +void *__objc_class_name_OFUTF8String; static void __attribute__((__used__)) ctor(void) { static bool initialized = false; @@ -395,10 +403,16 @@ size_t of_alignof_type_encoding(const char *type) { return glue_of_alignof_type_encoding(type); } + +uint32_t * +of_hash_seed_ref(void) +{ + return glue_of_hash_seed_ref(); +} OFStdIOStream ** of_stdin_ref(void) { return glue_of_stdin_ref(); @@ -419,10 +433,46 @@ void of_logv(OFConstantString *format, va_list arguments) { glue_of_logv(format, arguments); } + +of_string_encoding_t +of_string_parse_encoding(OFString *string) +{ + return glue_of_string_parse_encoding(string); +} + +OFString * +of_string_name_of_encoding(of_string_encoding_t encoding) +{ + return glue_of_string_name_of_encoding(encoding); +} + +size_t +of_string_utf8_encode(of_unichar_t c, char *UTF8) +{ + return glue_of_string_utf8_encode(c, UTF8); +} + +ssize_t +of_string_utf8_decode(const char *UTF8, size_t len, of_unichar_t *c) +{ + return glue_of_string_utf8_decode(UTF8, len, c); +} + +size_t +of_string_utf16_length(const of_char16_t *string) +{ + return glue_of_string_utf16_length(string); +} + +size_t +of_string_utf32_length(const of_char32_t *string) +{ + return glue_of_string_utf32_length(string); +} OFString * of_zip_archive_entry_version_to_string(uint16_t version) { return glue_of_zip_archive_entry_version_to_string(version); @@ -449,10 +499,29 @@ unsigned char *key, size_t keyLength, bool allowsSwappableMemory) { glue_of_pbkdf2(HMAC, iterations, salt, saltLength, password, passwordLength, key, keyLength, allowsSwappableMemory); } + +void +of_salsa20_8_core(uint32_t *buffer) +{ + glue_of_salsa20_8_core(buffer); +} + +void +of_scrypt_block_mix(uint32_t *output, const uint32_t *input, size_t blockSize) +{ + glue_of_scrypt_block_mix(output, input, blockSize); +} + +void +of_scrypt_romix(uint32_t *buffer, size_t blockSize, size_t costFactor, + uint32_t *tmp) +{ + glue_of_scrypt_romix(buffer, blockSize, costFactor, tmp); +} void of_scrypt(size_t blockSize, size_t costFactor, size_t parallelization, const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, size_t keyLength, @@ -459,10 +528,16 @@ bool allowsSwappableMemory) { glue_of_scrypt(blockSize, costFactor, parallelization, salt, saltLength, password, passwordLength, key, keyLength, allowsSwappableMemory); } + +const char * +of_strptime(const char *buf, const char *fmt, struct tm *tm, int16_t *tz) +{ + return glue_of_strptime(buf, fmt, tm, tz); +} of_socket_address_t of_socket_address_parse_ip(OFString *IP, uint16_t port) { of_socket_address_t address; Index: src/of_strptime.h ================================================================== --- src/of_strptime.h +++ src/of_strptime.h @@ -29,12 +29,12 @@ OF_ASSUME_NONNULL_BEGIN #ifdef __cplusplus extern "C" { #endif -extern const char *of_strptime(const char *buf, const char *fmt, - struct tm *tm, int16_t *tz); +extern const char *_Nullable of_strptime(const char *buf, const char *fmt, + struct tm *tm, int16_t *_Nullable tz); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END