Changeset 40ec7e1 in umon


Ignore:
Timestamp:
Aug 6, 2015, 12:42:07 AM (4 years ago)
Author:
Ed Sutter <edsutterjr@…>
Branches:
master
Children:
d355df2
Parents:
ad25184
Message:

update to glib with clean indication of where the files (that I didn't create) came from

Location:
main/glib
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • main/glib/atoi.c

    rad25184 r40ec7e1  
    3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3232 * SUCH DAMAGE.
     33 *
     34 * Modified (removed locale) for use in Micromonitor
    3335 */
     36
     37#if defined(LIBC_SCCS) && !defined(lint)
     38static char sccsid[] = "@(#)atoi.c      8.1 (Berkeley) 6/4/93";
     39#endif /* LIBC_SCCS and not lint */
     40#include <sys/cdefs.h>
     41__FBSDID("$FreeBSD$");
    3442
    3543#include <stdlib.h>
  • main/glib/crc16.c

    rad25184 r40ec7e1  
     1/*
     2 * Copyright 2001-2010 Georges Menie (www.menie.org)
     3 * All rights reserved.
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions are met:
     6 *
     7 *     * Redistributions of source code must retain the above copyright
     8 *       notice, this list of conditions and the following disclaimer.
     9 *     * Redistributions in binary form must reproduce the above copyright
     10 *       notice, this list of conditions and the following disclaimer in the
     11 *       documentation and/or other materials provided with the distribution.
     12 *     * Neither the name of the University of California, Berkeley nor the
     13 *       names of its contributors may be used to endorse or promote products
     14 *       derived from this software without specific prior written permission.
     15 *
     16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
     17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
     20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26 *
     27 * Adapted for use in Micromonitor
     28 */
     29
    130#include "config.h"
    2 #include <ctype.h>
    3 #include "genlib.h"
    4 #include "stddefs.h"
    531
    6 /* CRC-CCITT crc16 used primarily by Xmodem...
    7  */
    8 ushort xcrc16tab[] = {
    9     0x0000,  0x1021,  0x2042,  0x3063,  0x4084,  0x50a5,  0x60c6,  0x70e7,
    10     0x8108,  0x9129,  0xa14a,  0xb16b,  0xc18c,  0xd1ad,  0xe1ce,  0xf1ef,
    11     0x1231,  0x0210,  0x3273,  0x2252,  0x52b5,  0x4294,  0x72f7,  0x62d6,
    12     0x9339,  0x8318,  0xb37b,  0xa35a,  0xd3bd,  0xc39c,  0xf3ff,  0xe3de,
    13     0x2462,  0x3443,  0x0420,  0x1401,  0x64e6,  0x74c7,  0x44a4,  0x5485,
    14     0xa56a,  0xb54b,  0x8528,  0x9509,  0xe5ee,  0xf5cf,  0xc5ac,  0xd58d,
    15     0x3653,  0x2672,  0x1611,  0x0630,  0x76d7,  0x66f6,  0x5695,  0x46b4,
    16     0xb75b,  0xa77a,  0x9719,  0x8738,  0xf7df,  0xe7fe,  0xd79d,  0xc7bc,
    17     0x48c4,  0x58e5,  0x6886,  0x78a7,  0x0840,  0x1861,  0x2802,  0x3823,
    18     0xc9cc,  0xd9ed,  0xe98e,  0xf9af,  0x8948,  0x9969,  0xa90a,  0xb92b,
    19     0x5af5,  0x4ad4,  0x7ab7,  0x6a96,  0x1a71,  0x0a50,  0x3a33,  0x2a12,
    20     0xdbfd,  0xcbdc,  0xfbbf,  0xeb9e,  0x9b79,  0x8b58,  0xbb3b,  0xab1a,
    21     0x6ca6,  0x7c87,  0x4ce4,  0x5cc5,  0x2c22,  0x3c03,  0x0c60,  0x1c41,
    22     0xedae,  0xfd8f,  0xcdec,  0xddcd,  0xad2a,  0xbd0b,  0x8d68,  0x9d49,
    23     0x7e97,  0x6eb6,  0x5ed5,  0x4ef4,  0x3e13,  0x2e32,  0x1e51,  0x0e70,
    24     0xff9f,  0xefbe,  0xdfdd,  0xcffc,  0xbf1b,  0xaf3a,  0x9f59,  0x8f78,
    25     0x9188,  0x81a9,  0xb1ca,  0xa1eb,  0xd10c,  0xc12d,  0xf14e,  0xe16f,
    26     0x1080,  0x00a1,  0x30c2,  0x20e3,  0x5004,  0x4025,  0x7046,  0x6067,
    27     0x83b9,  0x9398,  0xa3fb,  0xb3da,  0xc33d,  0xd31c,  0xe37f,  0xf35e,
    28     0x02b1,  0x1290,  0x22f3,  0x32d2,  0x4235,  0x5214,  0x6277,  0x7256,
    29     0xb5ea,  0xa5cb,  0x95a8,  0x8589,  0xf56e,  0xe54f,  0xd52c,  0xc50d,
    30     0x34e2,  0x24c3,  0x14a0,  0x0481,  0x7466,  0x6447,  0x5424,  0x4405,
    31     0xa7db,  0xb7fa,  0x8799,  0x97b8,  0xe75f,  0xf77e,  0xc71d,  0xd73c,
    32     0x26d3,  0x36f2,  0x0691,  0x16b0,  0x6657,  0x7676,  0x4615,  0x5634,
    33     0xd94c,  0xc96d,  0xf90e,  0xe92f,  0x99c8,  0x89e9,  0xb98a,  0xa9ab,
    34     0x5844,  0x4865,  0x7806,  0x6827,  0x18c0,  0x08e1,  0x3882,  0x28a3,
    35     0xcb7d,  0xdb5c,  0xeb3f,  0xfb1e,  0x8bf9,  0x9bd8,  0xabbb,  0xbb9a,
    36     0x4a75,  0x5a54,  0x6a37,  0x7a16,  0x0af1,  0x1ad0,  0x2ab3,  0x3a92,
    37     0xfd2e,  0xed0f,  0xdd6c,  0xcd4d,  0xbdaa,  0xad8b,  0x9de8,  0x8dc9,
    38     0x7c26,  0x6c07,  0x5c64,  0x4c45,  0x3ca2,  0x2c83,  0x1ce0,  0x0cc1,
    39     0xef1f,  0xff3e,  0xcf5d,  0xdf7c,  0xaf9b,  0xbfba,  0x8fd9,  0x9ff8,
    40     0x6e17,  0x7e36,  0x4e55,  0x5e74,  0x2e93,  0x3eb2,  0x0ed1,  0x1ef0
     32/* CRC16 implementation acording to CCITT standards */
     33
     34const unsigned short xcrc16tab[256]= {
     35    0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
     36    0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
     37    0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
     38    0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
     39    0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,
     40    0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
     41    0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,
     42    0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
     43    0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,
     44    0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
     45    0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
     46    0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
     47    0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,
     48    0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
     49    0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,
     50    0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
     51    0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,
     52    0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
     53    0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,
     54    0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
     55    0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,
     56    0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
     57    0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,
     58    0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
     59    0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,
     60    0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
     61    0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,
     62    0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
     63    0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,
     64    0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
     65    0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,
     66    0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
    4167};
    4268
    43 ushort
    44 xcrc16(uchar *buffer,ulong nbytes)
     69unsigned short crc16_ccitt(const void *buf, int len)
    4570{
    46     ulong   i;
    47     ushort  crc;
    48 
    49     crc = 0;
    50     for(i=0; i<nbytes; i++) {
    51         crc = (ushort)((crc << 8) ^ xcrc16tab[(crc>>8) ^ buffer[i]]);
     71    register int counter;
     72    register unsigned short crc = 0;
     73    for(counter = 0; counter < len; counter++) {
     74        crc = (crc<<8) ^ xcrc16tab[((crc>>8) ^ *(char *)buf++)&0x00FF];
    5275#ifdef WATCHDOG_ENABLED
    5376        /* Every 256 bytes call the watchdog macro... */
    54         if((nbytes & 0xff) == 0) {
     77        if((counter & 0xff) == 0) {
    5578            WATCHDOG_MACRO;
    5679        }
    5780#endif
    5881    }
    59     return(crc);
     82    return crc;
    6083}
     84
     85unsigned short
     86xcrc16(unsigned char *buffer,unsigned long nbytes)
     87{
     88    return(crc16_ccitt((const void *)buffer,(int)nbytes));
     89}
  • main/glib/getglib

    rad25184 r40ec7e1  
     1
     2#####
    13#
    2 # This is the original script I used to pull in files from the FreeBsd project:
     4# Where did this code come from?
     5# Some is home grown, most is straight out of freebsd untouched,
     6# some freebsd is touched, and a few are from external sources
     7# slightly modified...
     8# Note that all files that are untouched are pulled in and assigned
     9# the filename;  if they are touched, then the file is pulled in
     10# with a different name (to avoid overwriting the modified file).
     11
     12#####
    313#
    4 export GLIBFILES="abs.c atoi.c crc16.c crc32.c ctypetbl.c div.c getopt.c gmtime.c inrange.c lceil.c ldiv.c little_print.c memccpy.c memchr.c memcmp.c memcpy.c memset.c pollconsole.c prascii.c printmem.c smemcpy.c smemset.c sprnfloat.c strcasecmp.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c strnlen.c strpbrk.c strrchr.c strspn.c strstr.c strtod.c strtok.c strtol.c strtoul.c strtolower.c strtoupper.c swap.c ticktock.c ulceil.c"
     14# libc/string (untouched):
     15# bcopy.c:
     16wget -O bcopy.c https://svnweb.freebsd.org/base/head/lib/libc/string/bcopy.c?revision=251069&view=co
     17# memccpy.c:
     18wget -O memccpy.c https://svnweb.freebsd.org/base/head/lib/libc/string/memccpy.c?revision=251069&view=co
     19# memchr.c:
     20wget -O memchr.c https://svnweb.freebsd.org/base/head/lib/libc/string/memchr.c?revision=251069&view=co
     21# memcmp.c:
     22wget -O memcmp.chttps://svnweb.freebsd.org/base/head/lib/libc/string/memcmp.c?revision=251069&view=co
     23# memcpy.c:
     24wget -O memcpy.c https://svnweb.freebsd.org/base/head/lib/libc/string/memcpy.c?revision=92986&view=co
     25# memset.c:
     26wget -O memset.c https://svnweb.freebsd.org/base/head/lib/libc/string/memset.c?revision=251069&view=co
     27# strcat.c:
     28wget -O strcat.c https://svnweb.freebsd.org/base/head/lib/libc/string/strcat.c?revision=251069&view=co
     29# strchr.c:
     30wget -O strchr.c https://svnweb.freebsd.org/base/head/lib/libc/string/strchr.c?revision=251069&view=co
     31# strcmp.c:
     32wget -O strcmp.c https://svnweb.freebsd.org/base/head/lib/libc/string/strcmp.c?revision=251069&view=co
     33# strcpy.c:
     34wget -O strcpy.c https://svnweb.freebsd.org/base/head/lib/libc/string/strcpy.c?revision=251069&view=co
     35# strlen.c:
     36wget -O strlen.c https://svnweb.freebsd.org/base/head/lib/libc/string/strlen.c?revision=92889&view=co
     37# strncat.c:
     38wget -O strncat.c https://svnweb.freebsd.org/base/head/lib/libc/string/strncat.c?revision=251069&view=co
     39# strncmp.c:
     40wget -O strncmp.c https://svnweb.freebsd.org/base/head/lib/libc/string/strncmp.c?revision=251069&view=co
     41# strncpy.c:
     42wget -O strncpy.c https://svnweb.freebsd.org/base/head/lib/libc/string/strncpy.c?revision=251069&view=co
     43# strnlen.c:
     44wget -O strnlen.c https://svnweb.freebsd.org/base/head/lib/libc/string/strnlen.c?revision=189136&view=co
     45# strpbrk.c:
     46wget -O strpbrk.c https://svnweb.freebsd.org/base/head/lib/libc/string/strpbrk.c?revision=251069&view=co
     47# strrchr.c:
     48wget -O strrchr.c https://svnweb.freebsd.org/base/head/lib/libc/string/strrchr.c?revision=251069&view=co
     49# strstr.c:
     50wget -O strstr.c https://svnweb.freebsd.org/base/head/lib/libc/string/strstr.c?revision=251069&view=co
     51# strtok.c:
     52wget -O strtok.c https://svnweb.freebsd.org/base/head/lib/libc/string/strtok.c?revision=251069&view=co
    553
    6 export MYFILES="asctime.c inrange.c memcpy.c pollconsole.c prascii.c printmem.c smemcpy.c smemset.c swap.c ticktock.c"
     54#####
     55#
     56# libc/stdlib (untouched):
     57# abs.c:
     58wget -O abs.c https://svnweb.freebsd.org/base/head/lib/libc/stdlib/abs.c?revision=251069&view=co
     59# ldiv.c:
     60wget -O ldiv.c https://svnweb.freebsd.org/base/head/lib/libc/stdlib/ldiv.c?revision=251672&view=co
     61# div.c:
     62wget -O div.c https://svnweb.freebsd.org/base/head/lib/libc/stdlib/div.c?revision=251069&view=co
    763
    8 export BSDPATH=https://raw.githubusercontent.com/freebsd/freebsd/master
     64#####
     65#
     66# Miscellaneous functions modified, but derived from...
     67# (we download them here but don't overwrite the active version)
     68#
     69# crc16.c:
     70wget -O base_crc16.c http://www.menie.org/georges/embedded/crc16.c
     71# crc32.c:
     72wget https://svnweb.freebsd.org/base/stable/10/sys/libkern/crc32.c?revision=256281&view=co
     73# atoi.c (removed locale):
     74wget  https://svnweb.freebsd.org/base/head/lib/libc/stdlib/atoi.c?revision=251069&view=co
     75# strtol.c (removed locale):
     76wget https://svnweb.freebsd.org/base/head/lib/libc/stdlib/strtol.c?revision=251672&view=co
     77# strtoul.c (removed locale):
     78wget https://svnweb.freebsd.org/base/head/lib/libc/stdlib/strtoul.c?revision=251672&view=co
     79# strcasecmp.c (removed locale):
     80wget https://svnweb.freebsd.org/base/head/lib/libc/string/strcasecmp.c?revision=251069&view=co
     81# getopt.c (add getoptinit()):
     82wget https://svnweb.freebsd.org/base/head/lib/libc/stdlib/getopt.c?revision=267745&view=co
     83# asctime.c:
     84# Hand written written, based on http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html
    985
    10 export BSD_STRING_FILES="memccpy.c memchr.c memcmp.c memset.c strcasecmp.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c strnlen.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c"
     86#####
     87#
     88# Homegrown (written by Ed Sutter):
     89# inrange.c
     90# pollconsole.c
     91# prascii.c
     92# printmem.c
     93# smemcpy.c
     94# smemset.c
     95# ticktock.c
     96# swap.c
     97# strtolower.c
    1198
    12 export BSD_STDLIB_FILES="abs.c atoi.c div.c getopt.c ldiv.c strtol.c"
    13 
    14 rm -f *.c *.1 list
    15 
    16 for file in $MYFILES
    17 do
    18   cp orig/$file .
    19   echo "myfile: $file" >>list
    20 done
    21 
    22 for file in $BSD_STDLIB_FILES
    23 do
    24   if ! [ -f $file ]
    25   then
    26     wget ${BSDPATH}/lib/libc/stdlib/$file
    27     if [ $? == 0 ]
    28     then
    29       echo "stdlib: $file" >>list
    30     fi
    31   fi
    32 done
    33 
    34 for file in $BSD_STRING_FILES
    35 do
    36   if ! [ -f $file ]
    37   then
    38     wget ${BSDPATH}/lib/libc/string/$file
    39     if [ $? == 0 ]
    40     then
    41       echo "string: $file" >>list
    42     fi
    43   fi
    44 done
    45 
    46 wget ${BSDPATH}/contrib/tzcode/stdtime/asctime.c
    47 wget https://raw.githubusercontent.com/LADSoft/OrangeC/master/src/clibs/time/gmtime.c
    48 wget https://raw.githubusercontent.com/freebsd/freebsd-ports/master/converters/ta2as/files/strtolower.c
    49 wget https://raw.githubusercontent.com/freebsd/freebsd/master/sys/libkern/crc32.c
  • main/glib/getopt.c

    rad25184 r40ec7e1  
    11/*  $NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $ */
    2 #include <string.h>
    3 extern int printf(char *fmt,...);
    42
    53/*
     
    3028 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3129 * SUCH DAMAGE.
     30 *
     31 * Modified for use in Micromonitor.
    3232 */
     33
     34#if defined(LIBC_SCCS) && !defined(lint)
     35static char sccsid[] = "@(#)getopt.c    8.3 (Berkeley) 4/27/95";
     36#endif /* LIBC_SCCS and not lint */
     37#include <sys/cdefs.h>
     38__FBSDID("$FreeBSD$");
     39
     40#include <stdio.h>
     41#include <stdlib.h>
     42#include <string.h>
     43#include <unistd.h>
     44
    3345
    3446int opterr = 1,     /* if error message should be printed */
     
    7183               if the program (eg su) is looking for it. */
    7284            place = EMSG;
    73             if(strchr(ostr, '-') == 0) {
     85            if(strchr(ostr, '-') == NULL) {
    7486                return (-1);
    7587            }
     
    8193
    8294    /* See if option letter is one the caller wanted... */
    83     if(optopt == ':' || (oli = strchr(ostr, optopt)) == 0) {
     95    if(optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
    8496        if(*place == 0) {
    8597            ++optind;
    8698        }
    87         if(opterr && *ostr != ':')
    88             (void)printf(
    89                 "illegal option -- %c\n", optopt);
     99        if(opterr && *ostr != ':') {
     100            (void)printf("illegal option -- %c\n", optopt);
     101        }
    90102        return (BADCH);
    91103    }
     
    94106    if(oli[1] != ':') {
    95107        /* don't need argument */
    96         optarg = 0;
     108        optarg = NULL;
    97109        if(*place == 0) {
    98110            ++optind;
     
    109121             */
    110122        {
    111             optarg = 0;
     123            optarg = NULL;
    112124        } else if(nargc > ++optind) {
    113125            optarg = nargv[optind];
     
    119131            }
    120132            if(opterr)
    121                 (void)printf(
    122                     "option requires an argument -- %c\n",
    123                     optopt);
     133                (void)printf("option requires an argument -- %c\n",
     134                             optopt);
    124135            return (BADCH);
    125136        }
     
    130141}
    131142
    132 /* getoptinit():
    133  * Since getopt() can be used by every command in the monitor
    134  * it's variables must be reinitialized prior to each command
    135  * executed through docommand()...
    136  */
    137143void
    138144getoptinit(void)
    139145{
     146    opterr = 1;
    140147    optind = 1;
    141     opterr = 1;
    142148    optopt = 0;
    143149    optreset = 0;
    144     optarg = (char *)0;
     150    optarg = 0;
    145151}
  • main/glib/memccpy.c

    rad25184 r40ec7e1  
    3535
    3636#include <string.h>
    37 #include <stdlib.h>
    3837
    3938void *
  • main/glib/memchr.c

    rad25184 r40ec7e1  
    3838
    3939#include <string.h>
    40 #include <stdlib.h>
    4140
    4241void *
  • main/glib/memcpy.c

    rad25184 r40ec7e1  
    1 #include "config.h"
    2 #include <ctype.h>
    3 #include "genlib.h"
    4 #include "stddefs.h"
     1#include <sys/cdefs.h>
     2__FBSDID("$FreeBSD$");
    53
    6 #ifndef MEMCPY_CHUNK
    7 #define MEMCPY_CHUNK (256*1024)
    8 #endif
    9 
    10 /* memcpy():
    11  *  Copy n bytes from 'from' to 'to'; return 'to'.
    12  *  This version of memcpy() tries to take advantage of address alignment.
    13  *  The goal is to do as many of the copies on 4-byte aligned addresses,
    14  *  falling back to 2-byte alignment, and finally, if there is no other
    15  *  way, simple byte-by-byte copy.
    16  *  Note that there is some point where the amount of overhead may exceed
    17  *  the byte count; hence, this will take longer for small byte counts.
    18  *  The assumption here is that small byte count memcpy() calls don't really
    19  *  care.
    20  */
    21 char *
    22 memcpy(char *to,char *from,int count)
    23 {
    24     char    *to_copy, *end;
    25 #if INCLUDE_QUICKMEMCPY
    26     char    *tend;
    27 #endif
    28 
    29     to_copy = to;
    30 
    31 #if INCLUDE_QUICKMEMCPY
    32     /* If count is greater than 8, get fancy, else just do byte-copy... */
    33     if(count > 8) {
    34         /* Attempt to optimize the transfer here... */
    35         if(((int)to & 3) && ((int)from & 3)) {
    36             /* If from and to pointers are both unaligned to the
    37              * same degree then we can do a few char copies to get them
    38              * 4-byte aligned and then do a lot of 4-byte aligned copies.
    39              */
    40             if(((int)to & 3) == ((int)from & 3)) {
    41                 while((int)to & 3) {
    42                     *to++ = *from++;
    43                     count--;
    44                 }
    45             }
    46             /* If from and to pointers are both odd, but different, then
    47              * we can increment them both by 1 and do a bunch of 2-byte
    48              * aligned copies...
    49              */
    50             else if(((int)to & 1) && ((int)from & 1)) {
    51                 *to++ = *from++;
    52                 count--;
    53             }
    54         }
    55 
    56         /* If both pointers are now 4-byte aligned or 2-byte aligned,
    57          * take advantage of that here...
    58          */
    59         if(!((int)to & 3) && !((int)from & 3)) {
    60             tend = end = to + (count & ~3);
    61             count = count & 3;
    62 #ifdef WATCHDOG_ENABLED
    63             do {
    64                 tend = (end - to <= MEMCPY_CHUNK) ? end : to + MEMCPY_CHUNK;
    65 #endif
    66                 while(to < tend) {
    67                     *(ulong *)to = *(ulong *)from;
    68                     from += 4;
    69                     to += 4;
    70                 }
    71 #ifdef WATCHDOG_ENABLED
    72                 WATCHDOG_MACRO;
    73             } while(tend != end);
    74 #endif
    75         } else if(!((int)to & 1) && !((int)from & 1)) {
    76             tend = end = to + (count & ~1);
    77             count = count & 1;
    78 #ifdef WATCHDOG_ENABLED
    79             do {
    80                 tend = (end - to <= MEMCPY_CHUNK) ? end : to + MEMCPY_CHUNK;
    81 #endif
    82                 while(to < tend) {
    83                     *(ushort *)to = *(ushort *)from;
    84                     from += 2;
    85                     to += 2;
    86                 }
    87 #ifdef WATCHDOG_ENABLED
    88                 WATCHDOG_MACRO;
    89             } while(tend != end);
    90 #endif
    91         }
    92     }
    93 #endif
    94 
    95     if(count) {
    96         end = to + count;
    97         while(to < end) {
    98             *to++ = *from++;
    99         }
    100     }
    101     return(to_copy);
    102 }
    103 
    104 void
    105 bcopy(char *from, char *to, int size)
    106 {
    107     memcpy(to,from,size);
    108 }
     4#define MEMCOPY
     5#include "bcopy.c"
  • main/glib/strcasecmp.c

    rad25184 r40ec7e1  
    3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3232 * SUCH DAMAGE.
     33 *
     34 * Modified (removed locale) for use in Micromonitor.
    3335 */
    3436
     37#if defined(LIBC_SCCS) && !defined(lint)
     38static char sccsid[] = "@(#)strcasecmp.c        8.1 (Berkeley) 6/4/93";
     39#endif /* LIBC_SCCS and not lint */
     40#include <sys/cdefs.h>
     41__FBSDID("$FreeBSD$");
     42
     43#include <strings.h>
    3544#include <ctype.h>
    36 #include <stdlib.h>
    3745
    3846int
    3947strcasecmp(const char *s1, const char *s2)
    4048{
    41     const unsigned char
    42     *us1 = (const unsigned char *)s1,
    43      *us2 = (const unsigned char *)s2;
     49    const u_char
     50    *us1 = (const u_char *)s1,
     51     *us2 = (const u_char *)s2;
    4452
    4553    while(tolower(*us1) == tolower(*us2++))
     
    5462{
    5563    if(n != 0) {
    56         const unsigned char
    57         *us1 = (const unsigned char *)s1,
    58          *us2 = (const unsigned char *)s2;
     64        const u_char
     65        *us1 = (const u_char *)s1,
     66         *us2 = (const u_char *)s2;
    5967
    6068        do {
  • main/glib/strlen.c

    rad25184 r40ec7e1  
    1 #include "config.h"
    2 #include <ctype.h>
    3 #include "genlib.h"
    4 #include "stddefs.h"
     1/*-
     2 * Copyright (c) 1990, 1993
     3 *  The Regents of the University of California.  All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 3. All advertising materials mentioning features or use of this software
     14 *    must display the following acknowledgement:
     15 *  This product includes software developed by the University of
     16 *  California, Berkeley and its contributors.
     17 * 4. Neither the name of the University nor the names of its contributors
     18 *    may be used to endorse or promote products derived from this software
     19 *    without specific prior written permission.
     20 *
     21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31 * SUCH DAMAGE.
     32 */
    533
    6 /* strlen():
    7  * Returns the number of
    8  * non-NULL bytes in string argument.
    9  */
    10 int
    11 strlen(register char *s)
     34#if defined(LIBC_SCCS) && !defined(lint)
     35static char sccsid[] = "@(#)strlen.c    8.1 (Berkeley) 6/4/93";
     36#endif /* LIBC_SCCS and not lint */
     37#include <sys/cdefs.h>
     38__FBSDID("$FreeBSD$");
     39
     40#include <string.h>
     41
     42size_t
     43strlen(str)
     44const char *str;
    1245{
    13     register char *s0 = s + 1;
     46    const char *s;
    1447
    15     while(*s++ != '\0')
    16         ;
    17     return (s - s0);
     48    for(s = str; *s; ++s);
     49    return(s - str);
    1850}
     51
  • main/glib/strncat.c

    rad25184 r40ec7e1  
    3838
    3939#include <string.h>
    40 #include <stdlib.h>
    4140
    4241/*
  • main/glib/strncmp.c

    rad25184 r40ec7e1  
    3535
    3636#include <string.h>
    37 #include <stdlib.h>
    3837
    3938int
  • main/glib/strncpy.c

    rad25184 r40ec7e1  
    3838
    3939#include <string.h>
    40 #include <stdlib.h>
    4140
    4241/*
  • main/glib/strpbrk.c

    rad25184 r40ec7e1  
    3535
    3636#include <string.h>
    37 #include <stdlib.h>
    3837
    3938/*
  • main/glib/strstr.c

    rad25184 r40ec7e1  
    3838
    3939#include <string.h>
    40 #include <stdlib.h>
    4140
    4241/*
  • main/glib/strtol.c

    rad25184 r40ec7e1  
    3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3232 * SUCH DAMAGE.
     33 *
     34 * Modified (removed locale) for use in Micromonitor
    3335 */
    3436
     
    4143#include <limits.h>
    4244#include <ctype.h>
     45#include <errno.h>
    4346#include <stdlib.h>
    4447
     48#define HAVE_ERRNO 0
    4549
    4650/*
     
    138142    if(any < 0) {
    139143        acc = neg ? LONG_MIN : LONG_MAX;
     144#if HAVE_ERRNO
     145        errno = ERANGE;
     146#endif
    140147    } else if(!any) {
     148#if HAVE_ERRNO
     149noconv:
     150        errno = EINVAL;
     151#endif
    141152    } else if(neg) {
    142153        acc = -acc;
    143154    }
    144 
     155#if !HAVE_ERRNO
    145156noconv:
     157#endif
    146158    if(endptr != NULL) {
    147159        *endptr = (char *)(any ? s - 1 : nptr);
  • main/glib/strtoul.c

    rad25184 r40ec7e1  
    3131 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    3232 * SUCH DAMAGE.
     33 *
     34 * Modified (removed locale) for use in Micromonitor
    3335 */
    3436
     
    4143#include <limits.h>
    4244#include <ctype.h>
     45#include <errno.h>
    4346#include <stdlib.h>
     47
     48#define HAVE_ERRNO 0
    4449
    4550/*
     
    116121    if(any < 0) {
    117122        acc = ULONG_MAX;
     123#if HAVE_ERRNO
     124        errno = ERANGE;
     125#endif
    118126    } else if(!any) {
     127#if HAVE_ERRNO
     128noconv:
     129        errno = EINVAL;
     130#endif
    119131    } else if(neg) {
    120132        acc = -acc;
    121133    }
     134#if !HAVE_ERRNO
    122135noconv:
     136#endif
    123137    if(endptr != NULL) {
    124138        *endptr = (char *)(any ? s - 1 : nptr);
Note: See TracChangeset for help on using the changeset viewer.