2 * msvcrt.dll misc functions
4 * Copyright 2000 Jon Griffiths
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
27 #include "msvcrt/stdlib.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
34 /*********************************************************************
37 void _beep( unsigned int freq
, unsigned int duration
)
39 TRACE(":Freq %d, Duration %d\n",freq
,duration
);
43 /*********************************************************************
48 return (rand() & 0x7fff);
51 /*********************************************************************
54 void _sleep(unsigned long timeout
)
56 TRACE("_sleep for %ld milliseconds\n",timeout
);
57 Sleep((timeout
)?timeout
:1);
60 /*********************************************************************
63 void* _lfind(const void* match
, const void* start
,
64 unsigned int* array_size
, unsigned int elem_size
,
65 int (*cf
)(const void*,const void*) )
67 unsigned int size
= *array_size
;
71 if (cf(match
, start
) == 0)
72 return (void *)start
; /* found */
73 start
= (char*)start
+ elem_size
;
78 /*********************************************************************
81 void* _lsearch(const void* match
, void* start
,
82 unsigned int* array_size
, unsigned int elem_size
,
83 int (*cf
)(const void*,const void*) )
85 unsigned int size
= *array_size
;
89 if (cf(match
, start
) == 0)
90 return start
; /* found */
91 start
= (char*)start
+ elem_size
;
94 /* not found, add to end */
95 memcpy(start
, match
, elem_size
);
100 /*********************************************************************
103 * Trap to a debugger if the value of the stack pointer has changed.
112 * This function is available for iX86 only.
114 * When VC++ generates debug code, it stores the value of the stack pointer
115 * before calling any external function, and checks the value following
116 * the call. It then calls this function, which will trap if the values are
117 * not the same. Usually this means that the prototype used to call
118 * the function is incorrect. It can also mean that the .spec entry has
119 * the wrong calling convention or parameters.
124 __ASM_GLOBAL_FUNC(_chkesp
,
132 "call " __ASM_NAME("MSVCRT_chkesp_fail") "\n\t"
139 void MSVCRT_chkesp_fail(void)
141 ERR("Stack pointer incorrect after last function call - Bad prototype/spec entry?\n");
145 # else /* __GNUC__ */
146 void _chkesp(void) { }
147 # endif /* __GNUC__ */
149 #endif /* __i386__ */