mirror of
				https://github.com/teddysun/across.git
				synced 2025-10-31 08:45:36 +08:00 
			
		
		
		
	Added Alpine-based patches
This commit is contained in:
		
							
								
								
									
										274
									
								
								docker/mtproxy/patches/randr_compat.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										274
									
								
								docker/mtproxy/patches/randr_compat.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,274 @@ | ||||
| Index: jobs/jobs.h | ||||
| IDEA additional info: | ||||
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||||
| <+>UTF-8 | ||||
| =================================================================== | ||||
| --- jobs/jobs.h	(revision cdd348294d86e74442bb29bd6767e48321259bec) | ||||
| +++ jobs/jobs.h	(date 1527996954000) | ||||
| @@ -28,6 +28,8 @@ | ||||
|  #include "net/net-msg.h" | ||||
|  #include "net/net-timers.h" | ||||
|   | ||||
| +#include "common/randr_compat.h" | ||||
| + | ||||
|  #define __joblocked | ||||
|  #define __jobref | ||||
|   | ||||
| Index: common/server-functions.c | ||||
| IDEA additional info: | ||||
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||||
| <+>UTF-8 | ||||
| =================================================================== | ||||
| --- common/server-functions.c	(revision cdd348294d86e74442bb29bd6767e48321259bec) | ||||
| +++ common/server-functions.c	(date 1527998325000) | ||||
| @@ -35,7 +35,9 @@ | ||||
|  #include <arpa/inet.h> | ||||
|  #include <assert.h> | ||||
|  #include <errno.h> | ||||
| +#ifdef __GLIBC__ | ||||
|  #include <execinfo.h> | ||||
| +#endif | ||||
|  #include <fcntl.h> | ||||
|  #include <getopt.h> | ||||
|  #include <grp.h> | ||||
| @@ -168,6 +170,7 @@ | ||||
|  } | ||||
|   | ||||
|  void print_backtrace (void) { | ||||
| +#ifdef __GLIBC__ | ||||
|    void *buffer[64]; | ||||
|    int nptrs = backtrace (buffer, 64); | ||||
|    kwrite (2, "\n------- Stack Backtrace -------\n", 33); | ||||
| @@ -178,6 +181,7 @@ | ||||
|      kwrite (2, s, strlen (s)); | ||||
|      kwrite (2, "\n", 1); | ||||
|    } | ||||
| +#endif | ||||
|  } | ||||
|   | ||||
|  pthread_t debug_main_pthread_id; | ||||
| Index: common/randr_compat.h | ||||
| IDEA additional info: | ||||
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||||
| <+>UTF-8 | ||||
| =================================================================== | ||||
| --- common/randr_compat.h	(date 1527998264000) | ||||
| +++ common/randr_compat.h	(date 1527998264000) | ||||
| @@ -0,0 +1,72 @@ | ||||
| +/* | ||||
| +    The GNU C Library is free software.  See the file COPYING.LIB for copying | ||||
| +    conditions, and LICENSES for notices about a few contributions that require | ||||
| +    these additional notices to be distributed.  License copyright years may be | ||||
| +    listed using range notation, e.g., 2000-2011, indicating that every year in | ||||
| +    the range, inclusive, is a copyrightable year that would otherwise be listed | ||||
| +    individually. | ||||
| +*/ | ||||
| + | ||||
| +#pragma once | ||||
| + | ||||
| +#include <endian.h> | ||||
| +#include <pthread.h> | ||||
| + | ||||
| +struct drand48_data { | ||||
| +    unsigned short int __x[3];	/* Current state.  */ | ||||
| +    unsigned short int __old_x[3]; /* Old state.  */ | ||||
| +    unsigned short int __c;	/* Additive const. in congruential formula.  */ | ||||
| +    unsigned short int __init;	/* Flag for initializing.  */ | ||||
| +    unsigned long long int __a;	/* Factor in congruential formula.  */ | ||||
| +}; | ||||
| + | ||||
| +union ieee754_double | ||||
| +{ | ||||
| +    double d; | ||||
| + | ||||
| +    /* This is the IEEE 754 double-precision format.  */ | ||||
| +    struct | ||||
| +    { | ||||
| +#if	__BYTE_ORDER == __BIG_ENDIAN | ||||
| +        unsigned int negative:1; | ||||
| +        unsigned int exponent:11; | ||||
| +        /* Together these comprise the mantissa.  */ | ||||
| +        unsigned int mantissa0:20; | ||||
| +        unsigned int mantissa1:32; | ||||
| +#endif				/* Big endian.  */ | ||||
| +#if	__BYTE_ORDER == __LITTLE_ENDIAN | ||||
| +        /* Together these comprise the mantissa.  */ | ||||
| +        unsigned int mantissa1:32; | ||||
| +        unsigned int mantissa0:20; | ||||
| +        unsigned int exponent:11; | ||||
| +        unsigned int negative:1; | ||||
| +#endif				/* Little endian.  */ | ||||
| +    } ieee; | ||||
| + | ||||
| +    /* This format makes it easier to see if a NaN is a signalling NaN.  */ | ||||
| +    struct | ||||
| +    { | ||||
| +#if	__BYTE_ORDER == __BIG_ENDIAN | ||||
| +        unsigned int negative:1; | ||||
| +        unsigned int exponent:11; | ||||
| +        unsigned int quiet_nan:1; | ||||
| +        /* Together these comprise the mantissa.  */ | ||||
| +        unsigned int mantissa0:19; | ||||
| +        unsigned int mantissa1:32; | ||||
| +#else | ||||
| +        /* Together these comprise the mantissa.  */ | ||||
| +        unsigned int mantissa1:32; | ||||
| +        unsigned int mantissa0:19; | ||||
| +        unsigned int quiet_nan:1; | ||||
| +        unsigned int exponent:11; | ||||
| +        unsigned int negative:1; | ||||
| +#endif | ||||
| +    } ieee_nan; | ||||
| +}; | ||||
| + | ||||
| +#define IEEE754_DOUBLE_BIAS	0x3ff /* Added to exponent.  */ | ||||
| + | ||||
| +int drand48_r (struct drand48_data *buffer, double *result); | ||||
| +int lrand48_r (struct drand48_data *buffer, long int *result); | ||||
| +int mrand48_r (struct drand48_data *buffer, long int *result); | ||||
| +int srand48_r (long int seedval, struct drand48_data *buffer); | ||||
| \ No newline at end of file | ||||
| Index: Makefile | ||||
| IDEA additional info: | ||||
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||||
| <+>UTF-8 | ||||
| =================================================================== | ||||
| --- Makefile	(revision cdd348294d86e74442bb29bd6767e48321259bec) | ||||
| +++ Makefile	(date 1527998107000) | ||||
| @@ -40,6 +40,7 @@ | ||||
|  DEPENDENCE_NORM	:=	$(subst ${OBJ}/,${DEP}/,$(patsubst %.o,%.d,${OBJECTS})) | ||||
|   | ||||
|  LIB_OBJS_NORMAL := \ | ||||
| +	${OBJ}/common/randr_compat.o \ | ||||
|  	${OBJ}/common/crc32c.o \ | ||||
|  	${OBJ}/common/pid.o \ | ||||
|  	${OBJ}/common/sha1.o \ | ||||
| Index: common/randr_compat.c | ||||
| IDEA additional info: | ||||
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | ||||
| <+>UTF-8 | ||||
| =================================================================== | ||||
| --- common/randr_compat.c	(date 1527998213000) | ||||
| +++ common/randr_compat.c	(date 1527998213000) | ||||
| @@ -0,0 +1,120 @@ | ||||
| +/* | ||||
| +    The GNU C Library is free software.  See the file COPYING.LIB for copying | ||||
| +    conditions, and LICENSES for notices about a few contributions that require | ||||
| +    these additional notices to be distributed.  License copyright years may be | ||||
| +    listed using range notation, e.g., 2000-2011, indicating that every year in | ||||
| +    the range, inclusive, is a copyrightable year that would otherwise be listed | ||||
| +    individually. | ||||
| +*/ | ||||
| + | ||||
| +#include <stddef.h> | ||||
| +#include "common/randr_compat.h" | ||||
| + | ||||
| +int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) { | ||||
| +    uint64_t X; | ||||
| +    uint64_t result; | ||||
| + | ||||
| +    /* Initialize buffer, if not yet done.  */ | ||||
| +    if (!buffer->__init == 0) | ||||
| +    { | ||||
| +        buffer->__a = 0x5deece66dull; | ||||
| +        buffer->__c = 0xb; | ||||
| +        buffer->__init = 1; | ||||
| +    } | ||||
| + | ||||
| +    /* Do the real work.  We choose a data type which contains at least | ||||
| +       48 bits.  Because we compute the modulus it does not care how | ||||
| +       many bits really are computed.  */ | ||||
| + | ||||
| +    X = (uint64_t) xsubi[2] << 32 | (uint32_t) xsubi[1] << 16 | xsubi[0]; | ||||
| + | ||||
| +    result = X * buffer->__a + buffer->__c; | ||||
| + | ||||
| +    xsubi[0] = result & 0xffff; | ||||
| +    xsubi[1] = (result >> 16) & 0xffff; | ||||
| +    xsubi[2] = (result >> 32) & 0xffff; | ||||
| + | ||||
| +    return 0; | ||||
| +} | ||||
| + | ||||
| +int __erand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, double *result) { | ||||
| +    union ieee754_double temp; | ||||
| + | ||||
| +    /* Compute next state.  */ | ||||
| +    if (__drand48_iterate (xsubi, buffer) < 0) | ||||
| +        return -1; | ||||
| + | ||||
| +    /* Construct a positive double with the 48 random bits distributed over | ||||
| +       its fractional part so the resulting FP number is [0.0,1.0).  */ | ||||
| + | ||||
| +    temp.ieee.negative = 0; | ||||
| +    temp.ieee.exponent = IEEE754_DOUBLE_BIAS; | ||||
| +    temp.ieee.mantissa0 = (xsubi[2] << 4) | (xsubi[1] >> 12); | ||||
| +    temp.ieee.mantissa1 = ((xsubi[1] & 0xfff) << 20) | (xsubi[0] << 4); | ||||
| + | ||||
| +    /* Please note the lower 4 bits of mantissa1 are always 0.  */ | ||||
| +    *result = temp.d - 1.0; | ||||
| + | ||||
| +    return 0; | ||||
| +} | ||||
| + | ||||
| +int __nrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result) { | ||||
| +    /* Compute next state.  */ | ||||
| +    if (__drand48_iterate (xsubi, buffer) < 0) | ||||
| +        return -1; | ||||
| + | ||||
| +    /* Store the result.  */ | ||||
| +    if (sizeof (unsigned short int) == 2) | ||||
| +        *result = xsubi[2] << 15 | xsubi[1] >> 1; | ||||
| +    else | ||||
| +        *result = xsubi[2] >> 1; | ||||
| + | ||||
| +    return 0; | ||||
| +} | ||||
| + | ||||
| +int __jrand48_r (unsigned short int xsubi[3], struct drand48_data *buffer, long int *result) { | ||||
| +    /* Compute next state.  */ | ||||
| +    if (__drand48_iterate (xsubi, buffer) < 0) | ||||
| +        return -1; | ||||
| + | ||||
| +    /* Store the result.  */ | ||||
| +    *result = (int32_t) ((xsubi[2] << 16) | xsubi[1]); | ||||
| + | ||||
| +    return 0; | ||||
| +} | ||||
| + | ||||
| +int drand48_r (struct drand48_data *buffer, double *result) { | ||||
| +    return __erand48_r (buffer->__x, buffer, result); | ||||
| +} | ||||
| + | ||||
| +int lrand48_r (struct drand48_data *buffer, long int *result) { | ||||
| +    /* Be generous for the arguments, detect some errors.  */ | ||||
| +    if (buffer == NULL) | ||||
| +        return -1; | ||||
| + | ||||
| +    return __nrand48_r (buffer->__x, buffer, result); | ||||
| +} | ||||
| + | ||||
| +int mrand48_r (struct drand48_data *buffer, long int *result) { | ||||
| +    /* Be generous for the arguments, detect some errors.  */ | ||||
| +    if (buffer == NULL) | ||||
| +        return -1; | ||||
| + | ||||
| +    return __jrand48_r (buffer->__x, buffer, result); | ||||
| +} | ||||
| + | ||||
| +int srand48_r (long int seedval, struct drand48_data *buffer) { | ||||
| +    /* The standards say we only have 32 bits.  */ | ||||
| +    if (sizeof (long int) > 4) | ||||
| +        seedval &= 0xffffffffl; | ||||
| + | ||||
| +    buffer->__x[2] = seedval >> 16; | ||||
| +    buffer->__x[1] = seedval & 0xffffl; | ||||
| +    buffer->__x[0] = 0x330e; | ||||
| + | ||||
| +    buffer->__a = 0x5deece66dull; | ||||
| +    buffer->__c = 0xb; | ||||
| +    buffer->__init = 1; | ||||
| + | ||||
| +    return 0; | ||||
| +} | ||||
| \ No newline at end of file | ||||
		Reference in New Issue
	
	Block a user