2005-04-17 02:20:36 +04:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( c ) 1 9 9 6 , 1 9 9 8 , 1 9 9 9 , 2 0 0 4 b y R a l f B a e c h l e
* Copyright ( c ) 1 9 9 9 S i l i c o n G r a p h i c s , I n c .
* /
# include < a s m / a s m . h >
2005-09-10 00:32:31 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / r e g d e f . h >
# define E X ( i n s n ,r e g ,a d d r ,h a n d l e r ) \
9 : insn r e g , a d d r ; \
.section _ _ ex_ t a b l e ," a " ; \
PTR 9 b , h a n d l e r ; \
.previous
/ *
2011-03-31 05:57:33 +04:00
* Return t h e s i z e o f a s t r i n g i n c l u d i n g t h e e n d i n g N U L c h a r a c t e r u p t o a
2005-04-17 02:20:36 +04:00
* maximum o f a1 o r 0 i n c a s e o f e r r o r .
*
* Note : for p e r f o r m a n c e r e a s o n s w e d e l i b e r a t e l y a c c e p t t h a t a u s e r m a y
2013-01-22 15:59:30 +04:00
* make s t r l e n _ u s e r a n d s t r n l e n _ u s e r a c c e s s t h e f i r s t f e w K S E G 0
* bytes. T h e r e ' s n o t h i n g s e c r e t t h e r e . O n 6 4 - b i t a c c e s s i n g b e y o n d
* the m a x i m u m i s a t a d h a i r i e r . . .
2005-04-17 02:20:36 +04:00
* /
2014-01-02 20:19:49 +04:00
.macro __BUILD_STRNLEN_ASM func
LEAF( _ _ s t r n l e n _ \ f u n c \ ( ) _ a s m )
2005-04-17 02:20:36 +04:00
LONG_ L v0 , T I _ A D D R _ L I M I T ( $ 2 8 ) # p o i n t e r o k ?
and v0 , a0
2014-01-02 20:19:49 +04:00
bnez v0 , . L f a u l t \ @
2005-04-17 02:20:36 +04:00
2014-01-02 20:19:49 +04:00
FEXPORT( _ _ s t r n l e n _ \ f u n c \ ( ) _ n o c h e c k _ a s m )
2005-04-17 02:20:36 +04:00
move v0 , a0
PTR_ A D D U a1 , a0 # s t o p p o i n t e r
2015-05-28 19:46:49 +03:00
1 :
# ifdef C O N F I G _ C P U _ D A D D I _ W O R K A R O U N D S
.set noat
li A T , 1
# endif
beq v0 , a1 , 1 f # l i m i t r e a c h e d ?
2013-12-09 19:28:10 +04:00
.ifeqs " \ func" , " k e r n e l "
2014-01-02 20:19:49 +04:00
EX( l b , t 0 , ( v0 ) , . L f a u l t \ @)
2013-12-09 19:28:10 +04:00
.else
EX( l b e , t 0 , ( v0 ) , . L f a u l t \ @)
.endif
2014-11-04 13:54:29 +03:00
.set noreorder
2005-04-17 02:20:36 +04:00
bnez t 0 , 1 b
2015-05-28 19:46:49 +03:00
1 :
# ifndef C O N F I G _ C P U _ D A D D I _ W O R K A R O U N D S
PTR_ A D D I U v0 , 1
# else
PTR_ A D D U v0 , A T
.set at
# endif
2014-11-04 13:54:29 +03:00
.set reorder
PTR_ S U B U v0 , a0
2005-04-17 02:20:36 +04:00
jr r a
2014-01-02 20:19:49 +04:00
END( _ _ s t r n l e n _ \ f u n c \ ( ) _ a s m )
2005-04-17 02:20:36 +04:00
2014-01-02 20:19:49 +04:00
.Lfault \ @:
2008-01-29 13:14:59 +03:00
move v0 , z e r o
2005-04-17 02:20:36 +04:00
jr r a
2014-01-02 20:19:49 +04:00
.endm
2013-12-09 19:28:10 +04:00
# ifndef C O N F I G _ E V A
/* Set aliases */
.global __strnlen_user_asm
.global __strnlen_user_nocheck_asm
.set _ _ strnlen_ u s e r _ a s m , _ _ s t r n l e n _ k e r n e l _ a s m
.set _ _ strnlen_ u s e r _ n o c h e c k _ a s m , _ _ s t r n l e n _ k e r n e l _ n o c h e c k _ a s m
# endif
_ _ BUILD_ S T R N L E N _ A S M k e r n e l
# ifdef C O N F I G _ E V A
.set push
.set eva
2014-01-02 20:19:49 +04:00
_ _ BUILD_ S T R N L E N _ A S M u s e r
2013-12-09 19:28:10 +04:00
.set pop
# endif