Changeset 3899 for branches


Ignore:
Timestamp:
Oct 22, 2014, 9:17:00 PM (11 years ago)
Author:
bird
Message:

trunk+0.6: Modified the existing swab() function in string.h to be standard compliant (signed last argument, don't copy negative counts, truncate odd values instead of ignoring them). Fixes #281.

Location:
branches/libc-0.6/src/emx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/string.h

    r3809 r3899  
    120120size_t   strxfrm(char * __restrict, const char * __restrict, size_t);
    121121#if __BSD_VISIBLE
    122 void     swab(const void *, void *, size_t);
     122# ifndef _SWAB_DECLARED                                 /* bird: also in unistd.h */
     123#  define _SWAB_DECLARED                                /* bird: also in unistd.h */
     124#  if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T)
     125typedef __ssize_t       ssize_t;
     126#   define _SSIZE_T_DECLARED
     127#   define _SSIZE_T
     128#  endif
     129void     swab(const void * __restrict, void * __restrict, ssize_t);
     130# endif /* !_SWAB_DECLARED */                           /* bird: also in unistd.h  */
    123131#endif
    124132
  • branches/libc-0.6/src/emx/include/unistd.h

    r2455 r3899  
    455455int      setregid(gid_t, gid_t);
    456456int      setreuid(uid_t, uid_t);
    457 /* void  swab(const void * __restrict, void * __restrict, ssize_t); */
     457
     458#ifndef _SWAB_DECLARED                                  /* bird: also in string.h */
     459# define _SWAB_DECLARED                                 /* bird: also in string.h */
     460void     swab(const void * __restrict, void * __restrict, ssize_t);
     461#endif /* !_SWAB_DECLARED */                            /* bird: also in string.h */
    458462void     sync(void);
    459463useconds_t       ualarm(useconds_t, useconds_t);
  • branches/libc-0.6/src/emx/src/lib/str/386/swab.s

    r236 r3899  
    11/ swab.s (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
     2/                  -- Copyright (c) 2014 Knut St. Osmundsen <bird-srcspam@anduin.net>
    23
    34#include <emx/asm386.h>
     
    56        .globl _STD(swab)
    67
    7 / void _swab (const void *src, void *dst, size_t n)
     8/ void _swab (const void *src, void *dst, ssize_t n)
    89/ {
    9 /   char *s, *d;
     10/   char *s = src, *d = dst;
    1011/
    1112/   if (n & 1) return;
     
    3132        movl    4*4(%esp), %edi         /* dst */
    3233        movl    5*4(%esp), %ecx         /* n */
     34
     35        testl   $0x80000000, %ecx       /* skip if negative count */
     36        jnz     Lreturn
    3337        shrl    $1, %ecx
    34         jc      Lreturn
    3538        jz      Lreturn
     39
    3640        ALIGN
    37411:      lodsw
     
    3943        stosw
    4044        loop    1b
     45
    4146Lreturn:popl    %edi
    4247        popl    %esi
Note: See TracChangeset for help on using the changeset viewer.