~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal

« back to all changes in this revision

Viewing changes to ubuntu/ndiswrapper/crt.c

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich, Andy Whitcroft, Chase Douglas, Eugeni Dodonov, Ingo Molnar, Johannes Berg, John Johansen, Kees Cook, Leann Ogasawara, Robert Hooker, Seth Heasley, Tim Gardner, Luke Yelavich, Upstream Kernel Changes
  • Date: 2012-03-09 10:21:12 UTC
  • Revision ID: package-import@ubuntu.com-20120309102112-s1abu8w051stx2rl
Tags: 3.2.0-18.26
[ Andy Whitcroft ]

* [Config] clean up the human consumable package descriptions
* [Config] fix generic flavour description
* [Config] clean up linux-tools package descriptions
  - LP: #593107
* deviations -- note the source of the Hyper-V updates
* SAUCE: ata_piix: defer to the Hyper-V drivers by default
  - LP: #929545
* ubuntu: AUFS -- adapt to the new changelog handling
* ubuntu: AUFS -- sort out the relative header paths
* ubuntu: AUFS -- update to d266b0c5d0693d6383976ee54b9e2c0fa9a3f5b0

[ Chase Douglas ]

* SAUCE: (drop after 3.3) HID: hid-magicmouse: Add pointer and buttonpad
  properties for Magic Trackpad
* SAUCE: Input: synaptics - add second variant of two-button clickpad
* SAUCE: Input: synapticss - Set buttonpad property for all clickpads

[ Eugeni Dodonov ]

* SAUCE: drm/i915: do not enable RC6p on Sandy Bridge
* SAUCE: drm/i915: fix operator precedence when enabling RC6p

[ Ingo Molnar ]

* ubuntu: nx-emu - i386: NX emulation

[ Johannes Berg ]

* SAUCE: iwlwifi: fix key removal
  - LP: #911059

[ John Johansen ]

* Revert "SAUCE: AppArmor: Fix unpack of network tables."
* Revert "SAUCE: AppArmor: Allow dfa backward compatibility with broken
  userspace"
* SAUCE: AppArmor: Add mising end of structure test to caps unpacking
* SAUCE: AppArmor: Fix dropping of allowed operations that are force
  audited
* SAUCE: AppArmor: Fix underflow in xindex calculation
* SAUCE: AppArmor: fix mapping of META_READ to audit and quiet flags
* SAUCE: AppArmor: Fix the error case for chroot relative path name
  lookup
  - LP: #925028
* SAUCE: AppArmor: Retrieve the dentry_path for error reporting when path
  lookup fails
  - LP: #925028
* SAUCE: AppArmor: Minor cleanup of d_namespace_path to consolidate error
  handling
* SAUCE: AppArmor: Update dfa matching routines.
* SAUCE: AppArmor: Move path failure information into aa_get_name and
  rename
* SAUCE: AppArmor: Make chroot relative the default path lookup type
* SAUCE: AppArmor: Add ability to load extended policy
* SAUCE: AppArmor: basic networking rules
* SAUCE: AppArmor: Add profile introspection file to interface
* SAUCE: AppArmor: Add the ability to mediate mount
* SAUCE: AppArmor: Add mount information to apparmorfs

[ Kees Cook ]

* SAUCE: (drop after 3.3) security: create task_free security callback
* SAUCE: (drop after 3.3) security: Yama LSM
* SAUCE: (drop after 3.3) Yama: add PR_SET_PTRACER_ANY
* SAUCE: Yama: add link restrictions
* SAUCE: security: unconditionally chain to Yama LSM
* SAUCE: AppArmor: refactor securityfs to use structures
* SAUCE: AppArmor: add initial "features" directory to securityfs
* SAUCE: AppArmor: add "file" details to securityfs
* SAUCE: AppArmor: export known rlimit names/value mappings in securityfs
* ubuntu: Yama - LSM hooks
* ubuntu: Yama - add ptrace relationship tracking interface
* ubuntu: Yama - unconditionally chain to Yama LSM

[ Leann Ogasawara ]

* Revert "[Config] Enable CONFIG_NVRAM=m"
  - LP: #942193
* Drop ndiswrapper
* Ubuntu-3.2.0-17.26
* Ubuntu-3.2.0-17.27
* Rebase to v3.2.7
* [Config] Enable CONFIG_USB_SERIAL_QUATECH2=m on arm and powerpc
* [Config] Enable CONFIG_USB_SERIAL_QUATECH_USB2=m on arm and powerpc
* [Config] Add CONFIG_NVRAM to config enforcer
  - LP: #942193
* [Config] Enable CONFIG_SCSI_IBMVSCSI=m for powerpc
  - LP: #943090
* [Config] Enable CONFIG_SCSI_IPR=m for powerpc
  - LP: #943090
* provide ipmi udeb
  - LP: #942926
* Rebase to v3.2.9
* Add ibmveth to d-i/modules-powerpc/nic-modules
  - LP: #712188
* [Config] Enable CONFIG_SCSI_IBMVFC=m for powerpc
  - LP: #712188
* Add ibmvfc and ibmvscsic to d-i/modules-powerpc/nic-modules
  - LP: #712188
* Ubuntu-3.2.0-18.28

[ Robert Hooker ]

* SAUCE: drm/i915: Enable RC6 by default on sandybridge.

[ Seth Heasley ]

* SAUCE: ALSA: hda - Add Lynx Point HD Audio Controller DeviceIDs
  - LP: #900119
* SAUCE: ahci: AHCI-mode SATA patch for Intel Lynx Point DeviceIDs
  - LP: #900119
* SAUCE: ata_piix: IDE-mode SATA patch for Intel Lynx Point DeviceIDs
  - LP: #900119
* SAUCE: i2c-i801: Add device IDs for Intel Lynx Point
  - LP: #900119

[ Tim Gardner ]

* dropped hv_mouse
* [Config] CONFIG_X86_NUMACHIP=y
* [Config] updateconfigs after apparmor patches
* [Config] Added hv_netvsc and hv_storvsc to -virtual
  - LP: #942256
* [Config] Enable aufs
  - LP: #943119
* SAUCE: Made kernel irq-threaded by default

[ Luke Yelavich ]

* UBUNTU: Depend on crda (>=1.1.1-1ubuntu2) | wireless-crda as per precise
  mainline packaging

[ Upstream Kernel Changes ]

* Revert "Revert "ath9k_hw: fix interpretation of the rx KeyMiss flag""
* Revert "AppArmor: compatibility patch for v5 interface"
* Revert "AppArmor: compatibility patch for v5 network controll"
* Staging: hv: vmbus: Support building the vmbus driver as part of the
  kernel
* hv: Add Kconfig menu entry
* Drivers: hv: Fix a memory leak
* Drivers: hv: Make the vmbus driver unloadable
* Drivers: hv: Get rid of an unnecessary check in hv.c
* Staging: hv: mousevsc: Make boolean states boolean
* Staging: hv: mousevsc: Inline the code for mousevsc_on_device_add()
* Staging: hv: mousevsc: Inline the code for reportdesc_callback()
* Staging: hv: mousevsc: Cleanup mousevsc_on_channel_callback()
* Staging: hv: mousevsc: Add a new line to a debug string
* Staging: hv: mousevsc: Get rid of unnecessary include files
* Staging: hv: mousevsc: Address some style issues
* Staging: hv: mousevsc: Add a check to prevent memory corruption
* Staging: hv: mousevsc: Use the KBUILD_MODNAME macro
* Staging: hv: storvsc: Use mempools to allocate struct
  storvsc_cmd_request
* Staging: hv: storvsc: Cleanup error handling in the probe function
* Staging: hv: storvsc: Fixup the error when processing SET_WINDOW
  command
* Staging: hv: storvsc: Fix error handling storvsc_host_reset()
* Staging: hv: storvsc: Use the accessor function shost_priv()
* Staging: hv: storvsc: Use the unlocked version queuecommand
* Staging: hv: storvsc: use the macro KBUILD_MODNAME
* Staging: hv: storvsc: Get rid of an unnecessary forward declaration
* Staging: hv: storvsc: Upgrade the vmstor protocol version
* Staging: hv: storvsc: Support hot add of scsi disks
* Staging: hv: storvsc: Support hot-removing of scsi devices
* staging: hv: Use kmemdup rather than duplicating its implementation
* staging: hv: move hv_netvsc out of staging area
* Staging: hv: mousevsc: Properly add the hid device
* Staging: hv: storvsc: Disable clustering
* Staging: hv: storvsc: Cleanup storvsc_device_alloc()
* Staging: hv: storvsc: Fix a bug in storvsc_command_completion()
* Staging: hv: storvsc: Fix a bug in copy_from_bounce_buffer()
* Staging: hv: storvsc: Implement per device memory pools
* Staging: hv: remove hv_mouse driver as it's now in the hid directory
* Staging: hv: update TODO file
* Staging: hv: storvsc: Fix a bug in create_bounce_buffer()
* net/hyperv: Fix long lines in netvsc.c
* net/hyperv: Add support for promiscuous mode setting
* net/hyperv: Fix the stop/wake queue mechanism
* net/hyperv: Remove unnecessary kmap_atomic in netvsc driver
* net/hyperv: Add NETVSP protocol version negotiation
* net/hyperv: Add support for jumbo frame up to 64KB
* net/hyperv: fix possible memory leak in do_set_multicast()
* net/hyperv: rx_bytes should account the ether header size
* net/hyperv: fix the issue that large packets be dropped under bridge
* net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when
  necessary
* net/hyperv: Fix the page buffer when an RNDIS message goes beyond page
  boundary
* HID: Move the hid-hyperv driver out of staging
* HID: hv_mouse: Properly add the hid device
* HID: hyperv: Properly disconnect the input device
* Staging: hv: storvsc: Cleanup some comments
* Staging: hv: storvsc: Cleanup storvsc_probe()
* Staging: hv: storvsc: Cleanup storvsc_queuecommand()
* Staging: hv: storvsc: Introduce defines for srb status codes
* Staging: hv: storvsc: Cleanup storvsc_host_reset_handler()
* Staging: hv: storvsc: Move and cleanup storvsc_remove()
* Staging: hv: storvsc: Add a comment to explain life-cycle management
* Staging: hv: storvsc: Get rid of the on_io_completion in
  hv_storvsc_request
* Staging: hv: storvsc: Rename the context field in hv_storvsc_request
* Staging: hv: storvsc: Miscellaneous cleanup of storvsc driver
* Staging: hv: storvsc: Cleanup the code for generating protocol version
* Staging: hv: storvsc: Cleanup some protocol related constants
* Staging: hv: storvsc: Get rid of some unused defines
* Staging: hv: storvsc: Consolidate the request structure
* Staging: hv: storvsc: Consolidate all the wire protocol definitions
* Staging: hv: storvsc: Move the storage driver out of the staging area
* x86: Make flat_init_apic_ldr() available
* x86: Add x86_init platform override to fix up NUMA core numbering
* x86: Add NumaChip support
* x86/numachip: Drop unnecessary conflict with EDAC
* Input: bcm5974 - set BUTTONPAD property
* Ubuntu: Rebase to v3.2.8
* ACPI / PM: Do not save/restore NVS on Asus K54C/K54HR
  - LP: #898503
* Add low latency source

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani
3
 
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
7
 
 *  (at your option) any later version.
8
 
 *
9
 
 *  This program is distributed in the hope that it will be useful,
10
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 
 *  GNU General Public License for more details.
13
 
 *
14
 
 */
15
 
 
16
 
#include "ntoskernel.h"
17
 
#include "crt_exports.h"
18
 
 
19
 
#ifdef CONFIG_X86_64
20
 
/* Windows long is 32-bit, so strip single 'l' in integer formats */
21
 
static void strip_l_modifier(char *str)
22
 
{
23
 
        char *ptr = str;
24
 
        int in_format = 0;
25
 
        char *lptr = NULL;
26
 
        char last = 0;
27
 
        char *end_ptr;
28
 
        char *wptr;
29
 
 
30
 
        /* Replace single 'l' inside integer formats with '\0' */
31
 
        for (ptr = str; *ptr; ptr++) {
32
 
                if (!in_format) {
33
 
                        if (*ptr == '%')
34
 
                                in_format = 1;
35
 
                        last = *ptr;
36
 
                        continue;
37
 
                }
38
 
                switch (*ptr) {
39
 
                case 'd':
40
 
                case 'i':
41
 
                case 'o':
42
 
                case 'u':
43
 
                case 'x':
44
 
                case 'X':
45
 
                case 'p':
46
 
                case 'n':
47
 
                case 'm':
48
 
                        if (lptr) {
49
 
                                *lptr = '\0';
50
 
                                lptr = NULL;
51
 
                        }
52
 
                        in_format = 0;
53
 
                        break;
54
 
                case 'c':
55
 
                case 'C':
56
 
                case 's':
57
 
                case 'S':
58
 
                case 'f':
59
 
                case 'e':
60
 
                case 'E':
61
 
                case 'g':
62
 
                case 'G':
63
 
                case 'a':
64
 
                case 'A':
65
 
                        lptr = NULL;
66
 
                        in_format = 0;
67
 
                        break;
68
 
                case '%':
69
 
                        lptr = NULL;
70
 
                        if (last == '%')
71
 
                                in_format = 0;
72
 
                        else
73
 
                                in_format = 1;  /* ignore previous junk */
74
 
                        break;
75
 
                case 'l':
76
 
                        if (last == 'l')
77
 
                                lptr = NULL;
78
 
                        else
79
 
                                lptr = ptr;
80
 
                        break;
81
 
                default:
82
 
                        break;
83
 
                }
84
 
                last = *ptr;
85
 
        }
86
 
 
87
 
        /* Purge zeroes from the resulting string */
88
 
        end_ptr = ptr;
89
 
        wptr = str;
90
 
        for (ptr = str; ptr < end_ptr; ptr++)
91
 
                if (*ptr != 0)
92
 
                        *(wptr++) = *ptr;
93
 
        *wptr = 0;
94
 
}
95
 
 
96
 
/*
97
 
 * va_list on x86_64 Linux is designed to allow passing arguments in registers
98
 
 * even to variadic functions.  va_list is a structure holding pointers to the
99
 
 * register save area, which holds the arguments passed in registers, and to
100
 
 * the stack, which may have the arguments that did not fit the registers.
101
 
 * va_list also holds offsets in the register save area for the next general
102
 
 * purpose and floating point registers that the next va_arg() would fetch.
103
 
 *
104
 
 * Unlike Linux, the Windows va_list is just a pointer to the stack.  No
105
 
 * arguments are passed in the registers.  That's why we construct the Linux
106
 
 * va_list so that the register save area is never used.  For that goal, we set
107
 
 * the offsets to the maximal allowed values, meaning that the arguments passed
108
 
 * in the registers have been exhausted.  The values are 48 for general purpose
109
 
 * registers (6 registers, 8 bytes each) and 304 for floating point registers
110
 
 * (16 registers, 16 bytes each, on top of general purpose register).
111
 
 */
112
 
 
113
 
struct x86_64_va_list {
114
 
        int gp_offset;
115
 
        int fp_offset;
116
 
        void *overflow_arg_area;
117
 
        void *reg_save_area;
118
 
};
119
 
 
120
 
#define VA_LIST_DECL(_args) \
121
 
        va_list _args##new; \
122
 
        struct x86_64_va_list *_args##x;
123
 
#define VA_LIST_PREP(_args) \
124
 
do { \
125
 
        _args##x = (struct x86_64_va_list *)&_args##new; \
126
 
        _args##x->gp_offset = 6 * 8;            /* GP registers exhausted */ \
127
 
        _args##x->fp_offset = 6 * 8 + 16 * 16;  /* FP registers exhausted */ \
128
 
        _args##x->overflow_arg_area = (void *)_args; \
129
 
        _args##x->reg_save_area = NULL; \
130
 
} while (0)
131
 
#define VA_LIST_CONV(_args) (_args##new)
132
 
#define VA_LIST_FREE(_args)
133
 
#define FMT_DECL(_fmt) \
134
 
        char *_fmt##copy; \
135
 
        int _fmt##len;
136
 
#define FMT_PREP(_fmt) \
137
 
do { \
138
 
        _fmt##len = strlen(format) + 1; \
139
 
        _fmt##copy = kmalloc(_fmt##len, GFP_KERNEL); \
140
 
        if (_fmt##copy) { \
141
 
                memcpy(_fmt##copy, format, _fmt##len); \
142
 
                strip_l_modifier(_fmt##copy); \
143
 
        } \
144
 
} while (0)
145
 
#define FMT_CONV(_fmt) (_fmt##copy ? _fmt##copy : format)
146
 
#define FMT_FREE(_fmt) kfree(_fmt##copy)
147
 
 
148
 
#else /* !CONFIG_X86_64 */
149
 
 
150
 
#define VA_LIST_DECL(_args)
151
 
#define VA_LIST_PREP(_args)
152
 
#define VA_LIST_CONV(_args) (_args)
153
 
#define VA_LIST_FREE(_args)
154
 
#define FMT_DECL(_fmt)
155
 
#define FMT_PREP(_fmt)
156
 
#define FMT_CONV(_fmt) (format)
157
 
#define FMT_FREE(_fmt)
158
 
 
159
 
#endif /* !CONFIG_X86_64 */
160
 
 
161
 
noregparm INT WIN_FUNC(_win_sprintf,12)
162
 
        (char *buf, const char *format, ...)
163
 
{
164
 
        va_list args;
165
 
        int res;
166
 
        FMT_DECL(format)
167
 
 
168
 
        FMT_PREP(format);
169
 
        va_start(args, format);
170
 
        res = vsprintf(buf, FMT_CONV(format), args);
171
 
        va_end(args);
172
 
        FMT_FREE(format);
173
 
 
174
 
        TRACE2("buf: %p: %s", buf, buf);
175
 
        return res;
176
 
}
177
 
 
178
 
noregparm INT WIN_FUNC(swprintf,12)
179
 
        (wchar_t *buf, const wchar_t *format, ...)
180
 
{
181
 
        TODO();
182
 
        EXIT2(return 0);
183
 
}
184
 
 
185
 
noregparm INT WIN_FUNC(_win_vsprintf,3)
186
 
        (char *str, const char *format, va_list ap)
187
 
{
188
 
        INT i;
189
 
        VA_LIST_DECL(ap)
190
 
        FMT_DECL(format)
191
 
 
192
 
        VA_LIST_PREP(ap);
193
 
        FMT_PREP(format);
194
 
 
195
 
        i = vsprintf(str, FMT_CONV(format), VA_LIST_CONV(ap));
196
 
        TRACE2("str: %p: %s", str, str);
197
 
 
198
 
        FMT_FREE(format);
199
 
        VA_LIST_FREE(ap);
200
 
        EXIT2(return i);
201
 
}
202
 
 
203
 
noregparm INT WIN_FUNC(_win_snprintf,12)
204
 
        (char *buf, SIZE_T count, const char *format, ...)
205
 
{
206
 
        va_list args;
207
 
        int res;
208
 
        FMT_DECL(format)
209
 
 
210
 
        FMT_PREP(format);
211
 
        va_start(args, format);
212
 
        res = vsnprintf(buf, count, FMT_CONV(format), args);
213
 
        va_end(args);
214
 
        TRACE2("buf: %p: %s", buf, buf);
215
 
 
216
 
        FMT_FREE(format);
217
 
        return res;
218
 
}
219
 
 
220
 
noregparm INT WIN_FUNC(_win__snprintf,12)
221
 
        (char *buf, SIZE_T count, const char *format, ...)
222
 
{
223
 
        va_list args;
224
 
        int res;
225
 
        FMT_DECL(format)
226
 
 
227
 
        FMT_PREP(format);
228
 
        va_start(args, format);
229
 
        res = vsnprintf(buf, count, FMT_CONV(format), args);
230
 
        va_end(args);
231
 
        TRACE2("buf: %p: %s", buf, buf);
232
 
 
233
 
        FMT_FREE(format);
234
 
        return res;
235
 
}
236
 
 
237
 
noregparm INT WIN_FUNC(_win_vsnprintf,4)
238
 
        (char *str, SIZE_T size, const char *format, va_list ap)
239
 
{
240
 
        INT i;
241
 
        VA_LIST_DECL(ap)
242
 
        FMT_DECL(format)
243
 
 
244
 
        VA_LIST_PREP(ap);
245
 
        FMT_PREP(format);
246
 
 
247
 
        i = vsnprintf(str, size, FMT_CONV(format), VA_LIST_CONV(ap));
248
 
        TRACE2("str: %p: %s", str, str);
249
 
 
250
 
        FMT_FREE(format);
251
 
        VA_LIST_FREE(ap);
252
 
        EXIT2(return i);
253
 
}
254
 
 
255
 
noregparm INT WIN_FUNC(_win__vsnprintf,4)
256
 
        (char *str, SIZE_T size, const char *format, va_list ap)
257
 
{
258
 
        INT i;
259
 
        VA_LIST_DECL(ap)
260
 
        FMT_DECL(format)
261
 
 
262
 
        VA_LIST_PREP(ap);
263
 
        FMT_PREP(format);
264
 
 
265
 
        i = vsnprintf(str, size, FMT_CONV(format), VA_LIST_CONV(ap));
266
 
        TRACE2("str: %p: %s", str, str);
267
 
 
268
 
        FMT_FREE(format);
269
 
        VA_LIST_FREE(ap);
270
 
        EXIT2(return i);
271
 
}
272
 
 
273
 
noregparm char *WIN_FUNC(_win_strncpy,3)
274
 
        (char *dst, char *src, SIZE_T n)
275
 
{
276
 
        return strncpy(dst, src, n);
277
 
}
278
 
 
279
 
noregparm SIZE_T WIN_FUNC(_win_strlen,1)
280
 
        (const char *s)
281
 
{
282
 
        return strlen(s);
283
 
}
284
 
 
285
 
noregparm INT WIN_FUNC(_win_strncmp,3)
286
 
        (const char *s1, const char *s2, SIZE_T n)
287
 
{
288
 
        return strncmp(s1, s2, n);
289
 
}
290
 
 
291
 
noregparm INT WIN_FUNC(_win_strcmp,2)
292
 
        (const char *s1, const char *s2)
293
 
{
294
 
        return strcmp(s1, s2);
295
 
}
296
 
 
297
 
noregparm INT WIN_FUNC(_win_stricmp,2)
298
 
        (const char *s1, const char *s2)
299
 
{
300
 
        return stricmp(s1, s2);
301
 
}
302
 
 
303
 
noregparm char *WIN_FUNC(_win_strncat,3)
304
 
        (char *dest, const char *src, SIZE_T n)
305
 
{
306
 
        return strncat(dest, src, n);
307
 
}
308
 
 
309
 
noregparm INT WIN_FUNC(_win_wcscmp,2)
310
 
        (const wchar_t *s1, const wchar_t *s2)
311
 
{
312
 
        while (*s1 && *s1 == *s2) {
313
 
                s1++;
314
 
                s2++;
315
 
        }
316
 
        return *s1 - *s2;
317
 
}
318
 
 
319
 
noregparm INT WIN_FUNC(_win_wcsicmp,2)
320
 
        (const wchar_t *s1, const wchar_t *s2)
321
 
{
322
 
        while (*s1 && tolower((char)*s1) == tolower((char)*s2)) {
323
 
                s1++;
324
 
                s2++;
325
 
        }
326
 
        return tolower((char)*s1) - tolower((char)*s2);
327
 
}
328
 
 
329
 
noregparm SIZE_T WIN_FUNC(_win_wcslen,1)
330
 
        (const wchar_t *s)
331
 
{
332
 
        const wchar_t *t = s;
333
 
        while (*t)
334
 
                t++;
335
 
        return t - s;
336
 
}
337
 
 
338
 
noregparm wchar_t *WIN_FUNC(_win_wcsncpy,3)
339
 
        (wchar_t *dest, const wchar_t *src, SIZE_T n)
340
 
{
341
 
        const wchar_t *s;
342
 
        wchar_t *d;
343
 
        s = src + n;
344
 
        d = dest;
345
 
        while (src < s && (*d++ = *src++))
346
 
                ;
347
 
        if (s > src)
348
 
                memset(d, 0, (s - src) * sizeof(wchar_t));
349
 
        return dest;
350
 
}
351
 
 
352
 
noregparm wchar_t *WIN_FUNC(_win_wcscpy,2)
353
 
        (wchar_t *dest, const wchar_t *src)
354
 
{
355
 
        wchar_t *d = dest;
356
 
        while ((*d++ = *src++))
357
 
               ;
358
 
        return dest;
359
 
}
360
 
 
361
 
noregparm wchar_t *WIN_FUNC(_win_wcscat,2)
362
 
        (wchar_t *dest, const wchar_t *src)
363
 
{
364
 
        wchar_t *d;
365
 
        d = dest;
366
 
        while (*d)
367
 
                d++;
368
 
        while ((*d++ = *src++))
369
 
                ;
370
 
        return dest;
371
 
}
372
 
 
373
 
noregparm INT WIN_FUNC(_win_towupper,1)
374
 
        (wchar_t c)
375
 
{
376
 
        return toupper(c);
377
 
}
378
 
 
379
 
noregparm INT WIN_FUNC(_win_towlower,1)
380
 
        (wchar_t c)
381
 
{
382
 
        return tolower(c);
383
 
}
384
 
 
385
 
noregparm INT WIN_FUNC(_win_tolower,1)
386
 
        (INT c)
387
 
{
388
 
        return tolower(c);
389
 
}
390
 
 
391
 
noregparm INT WIN_FUNC(_win_toupper,1)
392
 
        (INT c)
393
 
{
394
 
        return toupper(c);
395
 
}
396
 
 
397
 
noregparm void *WIN_FUNC(_win_strcpy,2)
398
 
        (void *to, const void *from)
399
 
{
400
 
        return strcpy(to, from);
401
 
}
402
 
 
403
 
noregparm char *WIN_FUNC(_win_strstr,2)
404
 
        (const char *s1, const char *s2)
405
 
{
406
 
        return strstr(s1, s2);
407
 
}
408
 
 
409
 
noregparm char *WIN_FUNC(_win_strchr,2)
410
 
        (const char *s, int c)
411
 
{
412
 
        return strchr(s, c);
413
 
}
414
 
 
415
 
noregparm char *WIN_FUNC(_win_strrchr,2)
416
 
        (const char *s, int c)
417
 
{
418
 
        return strrchr(s, c);
419
 
}
420
 
 
421
 
noregparm void *WIN_FUNC(_win_memmove,3)
422
 
        (void *to, void *from, SIZE_T count)
423
 
{
424
 
        return memmove(to, from, count);
425
 
}
426
 
 
427
 
noregparm void *WIN_FUNC(_win_memchr,3)
428
 
        (const void *s, INT c, SIZE_T n)
429
 
{
430
 
        return memchr(s, c, n);
431
 
}
432
 
 
433
 
noregparm void *WIN_FUNC(_win_memcpy,3)
434
 
        (void *to, const void *from, SIZE_T n)
435
 
{
436
 
        return memcpy(to, from, n);
437
 
}
438
 
 
439
 
noregparm void *WIN_FUNC(_win_memset,3)
440
 
        (void *s, char c, SIZE_T count)
441
 
{
442
 
        return memset(s, c, count);
443
 
}
444
 
 
445
 
noregparm int WIN_FUNC(_win_memcmp,3)
446
 
        (void *s1, void *s2, SIZE_T n)
447
 
{
448
 
        return memcmp(s1, s2, n);
449
 
}
450
 
 
451
 
noregparm void WIN_FUNC(_win_srand,1)
452
 
        (UINT seed)
453
 
{
454
 
        net_srandom(seed);
455
 
}
456
 
 
457
 
noregparm int WIN_FUNC(rand,0)
458
 
        (void)
459
 
{
460
 
        char buf[6];
461
 
        int i, n;
462
 
 
463
 
        get_random_bytes(buf, sizeof(buf));
464
 
        for (n = i = 0; i < sizeof(buf) ; i++)
465
 
                n += buf[i];
466
 
        return n;
467
 
}
468
 
 
469
 
noregparm int WIN_FUNC(_win_atoi,1)
470
 
        (const char *ptr)
471
 
{
472
 
        int i = simple_strtol(ptr, NULL, 10);
473
 
        return i;
474
 
}
475
 
 
476
 
noregparm int WIN_FUNC(_win_isprint,1)
477
 
        (int c)
478
 
{
479
 
        return isprint(c);
480
 
}
481
 
 
482
 
wstdcall s64 WIN_FUNC(_alldiv,2)
483
 
        (s64 a, s64 b)
484
 
{
485
 
        return a / b;
486
 
}
487
 
 
488
 
wstdcall u64 WIN_FUNC(_aulldiv,2)
489
 
        (u64 a, u64 b)
490
 
{
491
 
        return a / b;
492
 
}
493
 
 
494
 
wstdcall s64 WIN_FUNC(_allmul,2)
495
 
        (s64 a, s64 b)
496
 
{
497
 
        return a * b;
498
 
}
499
 
 
500
 
wstdcall u64 WIN_FUNC(_aullmul,2)
501
 
        (u64 a, u64 b)
502
 
{
503
 
        return a * b;
504
 
}
505
 
 
506
 
wstdcall s64 WIN_FUNC(_allrem,2)
507
 
        (s64 a, s64 b)
508
 
{
509
 
        return a % b;
510
 
}
511
 
 
512
 
wstdcall u64 WIN_FUNC(_aullrem,2)
513
 
        (u64 a, u64 b)
514
 
{
515
 
        return a % b;
516
 
}
517
 
 
518
 
__attribute__((regparm(3))) s64 WIN_FUNC(_allshl,2)
519
 
        (s64 a, u8 b)
520
 
{
521
 
        return a << b;
522
 
}
523
 
 
524
 
__attribute__((regparm(3))) u64 WIN_FUNC(_aullshl,2)
525
 
        (u64 a, u8 b)
526
 
{
527
 
        return a << b;
528
 
}
529
 
 
530
 
__attribute__((regparm(3))) s64 WIN_FUNC(_allshr,2)
531
 
        (s64 a, u8 b)
532
 
{
533
 
        return a >> b;
534
 
}
535
 
 
536
 
__attribute__((regparm(3))) u64 WIN_FUNC(_aullshr,2)
537
 
        (u64 a, u8 b)
538
 
{
539
 
        return a >> b;
540
 
}
541
 
 
542
 
int stricmp(const char *s1, const char *s2)
543
 
{
544
 
        while (*s1 && tolower(*s1) == tolower(*s2)) {
545
 
                s1++;
546
 
                s2++;
547
 
        }
548
 
        return *s1 - *s2;
549
 
}
550
 
 
551
 
void dump_bytes(const char *ctx, const u8 *from, int len)
552
 
{
553
 
        int i, j;
554
 
        u8 *buf;
555
 
 
556
 
        buf = kmalloc(len * 3 + 1, irql_gfp());
557
 
        if (!buf) {
558
 
                ERROR("couldn't allocate memory");
559
 
                return;
560
 
        }
561
 
        for (i = j = 0; i < len; i++, j += 3) {
562
 
                sprintf(&buf[j], "%02x ", from[i]);
563
 
        }
564
 
        buf[j] = 0;
565
 
        printk(KERN_DEBUG "%s: %p: %s\n", ctx, from, buf);
566
 
        kfree(buf);
567
 
}
568
 
 
569
 
int crt_init(void)
570
 
{
571
 
        return 0;
572
 
}
573
 
 
574
 
/* called when module is being removed */
575
 
void crt_exit(void)
576
 
{
577
 
        EXIT4(return);
578
 
}