KERNEL32: make lstr* functions inline inside Wine
Mike McCormack
mike at codeweavers.com
Tue Feb 22 00:40:55 CST 2005
By coverting the lstr functions to inline and removing the exception
handlers, we should be able to use them instead of the wine/unicode.h
functions without the performance penalty of an exception hander.
Hopefully, this will make porting (eg. to ReactOS) easier. After this
patch is applied, we can replace strlenW calls with lstrlenW calls, etc
in Wine.
Mike
ChangeLog:
* make lstr* functions inline inside Wine
-------------- next part --------------
Index: include/winbase.h
===================================================================
RCS file: /home/wine/wine/include/winbase.h,v
retrieving revision 1.224
diff -u -p -r1.224 winbase.h
--- include/winbase.h 3 Jan 2005 17:12:51 -0000 1.224
+++ include/winbase.h 22 Feb 2005 06:36:28 -0000
@@ -1966,18 +1966,103 @@ BOOL WINAPI WriteProfileStringA(L
BOOL WINAPI WriteProfileStringW(LPCWSTR,LPCWSTR,LPCWSTR);
#define WriteProfileString WINELIB_NAME_AW(WriteProfileString)
#define Yield()
+
+#if defined(WINE_NO_INLINE_STRING) || !defined(__WINESRC__)
+
LPSTR WINAPI lstrcatA(LPSTR,LPCSTR);
LPWSTR WINAPI lstrcatW(LPWSTR,LPCWSTR);
-#define lstrcat WINELIB_NAME_AW(lstrcat)
LPSTR WINAPI lstrcpyA(LPSTR,LPCSTR);
LPWSTR WINAPI lstrcpyW(LPWSTR,LPCWSTR);
-#define lstrcpy WINELIB_NAME_AW(lstrcpy)
LPSTR WINAPI lstrcpynA(LPSTR,LPCSTR,INT);
LPWSTR WINAPI lstrcpynW(LPWSTR,LPCWSTR,INT);
-#define lstrcpyn WINELIB_NAME_AW(lstrcpyn)
INT WINAPI lstrlenA(LPCSTR);
INT WINAPI lstrlenW(LPCWSTR);
+
+#else /* !defined(WINE_NO_INLINE_STRING) && defined(__WINESRC__) */
+
+/* string functions without the exception handler */
+
+static inline LPWSTR lstrcpynW( LPWSTR dst, LPCWSTR src, INT n )
+{
+ LPWSTR d = dst;
+ LPCWSTR s = src;
+ UINT count = n;
+
+ while ((count > 1) && *s)
+ {
+ count--;
+ *d++ = *s++;
+ }
+ if (count) *d = 0;
+ return dst;
+}
+
+static inline LPSTR lstrcpynA( LPSTR dst, LPCSTR src, INT n )
+{
+ LPSTR d = dst;
+ LPCSTR s = src;
+ UINT count = n;
+
+ while ((count > 1) && *s)
+ {
+ count--;
+ *d++ = *s++;
+ }
+ if (count) *d = 0;
+ return dst;
+}
+
+static inline INT lstrlenW( LPCWSTR str )
+{
+ const WCHAR *s = str;
+ while (*s) s++;
+ return s - str;
+}
+
+static inline INT lstrlenA( LPCSTR str )
+{
+ const CHAR *s = str;
+ while (*s) s++;
+ return s - str;
+}
+
+static inline LPWSTR lstrcpyW( LPWSTR dst, LPCWSTR src )
+{
+ WCHAR *p = dst;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+static inline LPSTR lstrcpyA( LPSTR dst, LPCSTR src )
+{
+ CHAR *p = dst;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+static inline LPWSTR lstrcatW( LPWSTR dst, LPCWSTR src )
+{
+ WCHAR *p = dst;
+ while (*p) p++;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+static inline LPSTR lstrcatA( LPSTR dst, LPCSTR src )
+{
+ CHAR *p = dst;
+ while (*p) p++;
+ while ((*p++ = *src++));
+ return dst;
+}
+
+#endif /* !defined(WINE_NO_INLINE_STRING) && defined(__WINESRC__) */
+
+#define lstrcat WINELIB_NAME_AW(lstrcat)
+#define lstrcpy WINELIB_NAME_AW(lstrcpy)
+#define lstrcpyn WINELIB_NAME_AW(lstrcpyn)
#define lstrlen WINELIB_NAME_AW(lstrlen)
+
LONG WINAPI _hread(HFILE,LPVOID,LONG);
LONG WINAPI _hwrite(HFILE,LPCSTR,LONG);
HFILE WINAPI _lcreat(LPCSTR,INT);
Index: dlls/shell32/shell32.spec
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32.spec,v
retrieving revision 1.93
diff -u -p -r1.93 shell32.spec
--- dlls/shell32/shell32.spec 21 Feb 2005 18:37:33 -0000 1.93
+++ dlls/shell32/shell32.spec 22 Feb 2005 06:36:28 -0000
@@ -252,13 +252,13 @@
306 stdcall StrCmpNIA(str str long) shlwapi.StrCmpNIA
307 stdcall StrCmpNIW(wstr wstr long) shlwapi.StrCmpNIW
308 stdcall StrCmpNW(wstr wstr long) shlwapi.StrCmpNW
- 309 stdcall StrCpyNA (ptr str long) lstrcpynA
+ 309 stdcall StrCpyNA (ptr str long) kernel32.lstrcpynA
310 stdcall StrCpyNW(wstr wstr long) shlwapi.StrCpyNW
311 stdcall StrNCmpA(str str long) shlwapi.StrCmpNA
312 stdcall StrNCmpIA(str str long) shlwapi.StrCmpNIA
313 stdcall StrNCmpIW(wstr wstr long) shlwapi.StrCmpNIW
314 stdcall StrNCmpW(wstr wstr long) shlwapi.StrCmpNW
- 315 stdcall StrNCpyA (ptr str long) lstrcpynA
+ 315 stdcall StrNCpyA (ptr str long) kernel32.lstrcpynA
316 stdcall StrNCpyW(wstr wstr long) shlwapi.StrCpyNW
317 stdcall StrRChrA(str str long) shlwapi.StrRChrA
318 stdcall StrRChrIA(str str long) shlwapi.StrRChrIA
Index: dlls/unicows/unicows.spec
===================================================================
RCS file: /home/wine/wine/dlls/unicows/unicows.spec,v
retrieving revision 1.3
diff -u -p -r1.3 unicows.spec
--- dlls/unicows/unicows.spec 3 Jan 2005 20:30:57 -0000 1.3
+++ dlls/unicows/unicows.spec 22 Feb 2005 06:36:28 -0000
@@ -476,12 +476,12 @@
@ stdcall capCreateCaptureWindowW(wstr long long long long long long long)
@ stdcall capGetDriverDescriptionW(long ptr long ptr long)
@ stdcall joyGetDevCapsW(long ptr long)
-@ stdcall lstrcatW(wstr wstr)
+@ stdcall lstrcatW(wstr wstr) kernel32.lstrcatW
@ stdcall lstrcmpW(wstr wstr)
@ stdcall lstrcmpiW(wstr wstr)
-@ stdcall lstrcpyW(ptr wstr)
-@ stdcall lstrcpynW(ptr wstr long)
-@ stdcall lstrlenW(wstr)
+@ stdcall lstrcpyW(ptr wstr) kernel32.lstrcpyW
+@ stdcall lstrcpynW(ptr wstr long) kernel32.lstrcpynW
+@ stdcall lstrlenW(wstr) kernel32.lstrlenW
@ stdcall mciGetDeviceIDW(str)
@ stdcall mciGetErrorStringW(long ptr long)
@ stdcall mciSendCommandW(long long long long)
More information about the wine-patches
mailing list