From: Apple Date: Tue, 9 Apr 2013 22:55:29 +0000 (+0000) Subject: Libc-825.26.tar.gz X-Git-Tag: mac-os-x-1083^0 X-Git-Url: https://git.saurik.com/apple/libc.git/commitdiff_plain/1a9403b782cb887866791b9ddebc3226b6ebd6a2 Libc-825.26.tar.gz --- diff --git a/gen/asl_fd.c b/gen/asl_fd.c index 74e3838..af60ccf 100644 --- a/gen/asl_fd.c +++ b/gen/asl_fd.c @@ -80,26 +80,34 @@ static inline int _read_redirect(int descriptor, int flush) { /* Increment our returned number read */ total_read += nbytes; - nbytes += (aslr->w - aslr->buf); - aslr->buf[nbytes] = '\0'; + /* Increment our write location */ + aslr->w += nbytes; + aslr->w[0] = '\0'; /* One line at a time */ - for (p=aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) { - // Find null or \n + for (p = aslr->buf; p < aslr->w; p = s + 1) { + /* Find null or \n */ for (s=p; *s && *s != '\n'; s++); + if (*s == '\n') { *s='\0'; + } + + if (s < aslr->w || aslr->buf == p) { + /* Either the first of multiple messages or one message which is larger than our buffer */ asl_log((aslclient)aslr->asl, (aslmsg)aslr->msg, aslr->level, "%s", p); - } else if (aslr->buf != p) { + } else { + /* We reached the end of the buffer, move this chunk to the start. */ memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf)); aslr->w = aslr->buf + (s - p); break; - } else if (nbytes == BUF_SIZE - 1) { - asl_log((aslclient)aslr->asl, (aslmsg)aslr->msg, aslr->level, "%s", p); - aslr->w = aslr->buf; - break; } } + + if (p == aslr->w) { + /* Start writing at the beginning in the case where we cleared the buffer */ + aslr->w = aslr->buf; + } } /* Flush if requested or we're at EOF */ @@ -194,14 +202,14 @@ static int asl_log_from_descriptor(aslclient ac, aslmsg am, int level, int descr /* Reallocate if we need more space */ if (descriptor >= n_redirect_descriptors) { - size_t new_n = 1 << (ffs(descriptor) + 1); + size_t new_n = 1 << (fls(descriptor) + 1); asl_redirect_t *new_array = realloc(redirect_descriptors, new_n * sizeof(*redirect_descriptors)); if (!new_array) { err = errno; return; } redirect_descriptors = new_array; - memset(redirect_descriptors + n_redirect_descriptors, 0, new_n - n_redirect_descriptors); + memset(redirect_descriptors + n_redirect_descriptors, 0, (new_n - n_redirect_descriptors) * sizeof(*redirect_descriptors)); n_redirect_descriptors = new_n; } diff --git a/i386/string/bzero_sse2.s b/i386/string/bzero_sse2.s index 2b3bdb8..6d03019 100644 --- a/i386/string/bzero_sse2.s +++ b/i386/string/bzero_sse2.s @@ -37,6 +37,7 @@ * since gcc sometimes silently maps bzero() into memset(). As a result, * we always load the original ptr into %eax before returning. */ + #define kShort 80 // too short to bother with SSE (must be >=80) #define kVeryLong (1024*1024) diff --git a/x86_64/string/bzero_sse2.s b/x86_64/string/bzero_sse2.s index fe94d28..3d7d596 100644 --- a/x86_64/string/bzero_sse2.s +++ b/x86_64/string/bzero_sse2.s @@ -37,6 +37,7 @@ * since gcc sometimes silently maps bzero() into memset(). As a result, * we always load the original ptr into %eax before returning. */ + #define kShort 80 // too short to bother with SSE (must be >=80) #define kVeryLong (1024*1024) diff --git a/xcodescripts/libc.xcconfig b/xcodescripts/libc.xcconfig index ba089eb..95bcf84 100644 --- a/xcodescripts/libc.xcconfig +++ b/xcodescripts/libc.xcconfig @@ -24,7 +24,6 @@ LD_DYLIB_INSTALL_NAME = /usr/lib/system/$(EXECUTABLE_NAME) BUILD_VARIANTS = normal debug -// clang is desired over llvm-gcc for OSAtomics. However, it isn't capable of building armv6 correctly on Sundance GCC_VERSION = com.apple.compilers.llvm.clang.1_0 GCC_VERSION[arch=armv6] = com.apple.compilers.llvmgcc42