~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to strings/strlen.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
/*  File   : strlen.c
17
 
    Author : Richard A. O'Keefe. / Monty
18
 
             Michael Widenius;  ifdef MC68000
19
 
    Updated: 1986-11-30
20
 
    Defines: strlen()
21
 
 
22
 
    strlen(s) returns the number of characters in s, that is, the number
23
 
    of non-NUL characters found before the closing NULEosCh.  Note: some
24
 
    non-standard C compilers for 32-bit machines take int to be 16 bits,
25
 
    either put up with short strings or change int  to  long  throughout
26
 
    this package.  Better yet, BOYCOTT such shoddy compilers.
27
 
    Beware: the asm version works only if strlen(s) < 65536.
28
 
*/
29
 
 
30
 
#include "strings.h"
31
 
 
32
 
#if VaxAsm
33
 
 
34
 
size_t strlen(char *s)
35
 
{
36
 
 asm("locc  $0,$65535,*4(ap)");
37
 
 asm("subl3 r0,$65535,r0");
38
 
}
39
 
 
40
 
#else
41
 
#if defined(MC68000) && defined(DS90)
42
 
 
43
 
size_t strlen(char *s)
44
 
{
45
 
asm("           movl    4(a7),a0        ");
46
 
asm("           movl    a0,a1           ");
47
 
asm(".L4:       tstb    (a0)+           ");
48
 
asm("           jne     .L4             ");
49
 
asm("           movl    a0,d0           ");
50
 
asm("           subl    a1,d0           ");
51
 
asm("           subql   #1,d0           ");
52
 
}
53
 
#else
54
 
 
55
 
size_t strlen(register char *s)
56
 
{
57
 
  register char *startpos;
58
 
 
59
 
  startpos = s;
60
 
  while (*s++);
61
 
  return ((size_t) (s-startpos-1));
62
 
}
63
 
 
64
 
#endif
65
 
#endif