AmendHub

Download (as of this amendment):

jcs

/

amend

/

amendments

/

138

util: Standardize on C99 uint*_t instead of u_int*_t in a stdint.h


jcs made amendment 138 over 2 years ago
--- diffreg.c Fri Feb 16 14:34:49 2024 +++ diffreg.c Thu Mar 7 17:15:15 2024 @@ -77,6 +77,9 @@ #include "diff.h" #include "util.h" +typedef unsigned char u_char; +typedef unsigned long u_int; + #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) --- stdint.h Thu Mar 7 17:15:02 2024 +++ stdint.h Thu Mar 7 17:26:00 2024 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 joshua stein <jcs@jcs.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef __STDINT_H__ +#define __STDINT_H__ + +#include <limits.h> + +/* stdbool.h */ +typedef Boolean bool; + +/* our own types */ +typedef signed long off_t; +typedef signed long ssize_t; + +/* ISO/IEC 988:1999, C99 */ +typedef unsigned long uint; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; + +#define SIZE_MAX ULONG_MAX + +#endif --- util.h Fri Feb 16 10:33:08 2024 +++ util.h Thu Mar 7 16:58:59 2024 @@ -18,16 +18,12 @@ #define __UTIL_H__ #include <stdlib.h> -#include <limits.h> +#include "stdint.h" #include <time.h> /* uncomment to enable malloc tracking */ #define MALLOC_DEBUG -#ifndef SIZE_MAX -#define SIZE_MAX ULONG_MAX -#endif - #define nitems(what) (sizeof((what)) / sizeof((what)[0])) #define member_size(type, member) sizeof(((type *)0)->member) @@ -61,19 +57,6 @@ #define TICKS_PER_SEC 60L #define MAX_TEXTEDIT_SIZE 32767L - -#ifndef bool -typedef Boolean bool; -#endif -typedef signed long off_t; -typedef signed long ssize_t; -typedef unsigned char u_char; -typedef unsigned long u_int; -typedef unsigned char u_int8_t; -typedef unsigned short u_int16_t; -typedef unsigned long u_int32_t; - -#define BYTE_ORDER BIG_ENDIAN typedef struct { short push[2], rts;