Add handling for drive options.
[wine/multimedia.git] / dlls / msvcrt / misc.c
blobae65d080ac8852ffc9dcab91b08d78dd79ea2f79
1 /*
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
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdlib.h>
26 #include "msvcrt.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
32 /*********************************************************************
33 * _beep (MSVCRT.@)
35 void _beep( unsigned int freq, unsigned int duration)
37 TRACE(":Freq %d, Duration %d\n",freq,duration);
38 Beep(freq, duration);
41 /*********************************************************************
42 * rand (MSVCRT.@)
44 int MSVCRT_rand()
46 return (rand() & 0x7fff);
49 /*********************************************************************
50 * _sleep (MSVCRT.@)
52 void _sleep(unsigned long timeout)
54 TRACE("_sleep for %ld milliseconds\n",timeout);
55 Sleep((timeout)?timeout:1);
58 /*********************************************************************
59 * _lfind (MSVCRT.@)
61 void* _lfind(const void* match, const void* start,
62 unsigned int* array_size, unsigned int elem_size,
63 int (*cf)(const void*,const void*) )
65 unsigned int size = *array_size;
66 if (size)
69 if (cf(match, start) == 0)
70 return (void *)start; /* found */
71 start = (char*)start + elem_size;
72 } while (--size);
73 return NULL;
76 /*********************************************************************
77 * _lsearch (MSVCRT.@)
79 void* _lsearch(const void* match, void* start,
80 unsigned int* array_size, unsigned int elem_size,
81 int (*cf)(const void*,const void*) )
83 unsigned int size = *array_size;
84 if (size)
87 if (cf(match, start) == 0)
88 return start; /* found */
89 start = (char*)start + elem_size;
90 } while (--size);
92 /* not found, add to end */
93 memcpy(start, match, elem_size);
94 array_size[0]++;
95 return start;
98 /*********************************************************************
99 * _chkesp (MSVCRT.@)
101 * Trap to a debugger if the value of the stack pointer has changed.
103 * PARAMS
104 * None.
106 * RETURNS
107 * Does not return.
109 * NOTES
110 * This function is available for iX86 only.
112 * When VC++ generates debug code, it stores the value of the stack pointer
113 * before calling any external function, and checks the value following
114 * the call. It then calls this function, which will trap if the values are
115 * not the same. Usually this means that the prototype used to call
116 * the function is incorrect. It can also mean that the .spec entry has
117 * the wrong calling convention or parameters.
119 #ifdef __i386__
121 # ifdef __GNUC__
123 __ASM_GLOBAL_FUNC(_chkesp,
124 "jnz 1f\n\t"
125 "ret\n"
126 "1:\tpushl %ebp\n\t"
127 "movl %esp,%ebp\n\t"
128 "pushl %eax\n\t"
129 "pushl %ecx\n\t"
130 "pushl %edx\n\t"
131 "call " __ASM_NAME("MSVCRT_chkesp_fail") "\n\t"
132 "popl %edx\n\t"
133 "popl %ecx\n\t"
134 "popl %eax\n\t"
135 "popl %ebp\n\t"
136 "ret");
138 void MSVCRT_chkesp_fail(void)
140 ERR("Stack pointer incorrect after last function call - Bad prototype/spec entry?\n");
141 DebugBreak();
144 # else /* __GNUC__ */
146 /**********************************************************************/
148 void _chkesp(void)
152 # endif /* __GNUC__ */
154 #endif /* __i386__ */