From 0006406f724d0788f86dea97c7efbe913b1eb00b Mon Sep 17 00:00:00 2001 From: "Doug Cook (WINDOWS)" Date: Mon, 4 Nov 2024 11:40:19 -0800 Subject: [PATCH] Rename if_re_bsd.h and rtlhw.cpp to match BSD driver To make it easier to relate the BSD driver sources to the Windows driver sources, restore the original BSD driver filenames: - `rtlhw.cpp` -> `if_re.c` - `if_re_bsd.h` -> `if_rereg.h` Also, compile the BSD sources using C rules instead of C++ rules, which hopefully make it easier to keep the BSD and Windows code aligned. Compiling as C code requires a few fixes: - Functions shared between C and C++ code need to be compiled as `extern "C"`. - To use `bool` in C code, you have to include the `stdbool.h` header. - During the build, the compiler can't use the same .pch for both C and C++ code, so only "precompile" the header for the C++ code (compile the C code without precompiled header acceleration). --- adapter.h | 10 +- bsdexport.h | 8 ++ rtlhw.cpp => if_re.c | 1 + if_re.vcxproj | 9 +- if_re.vcxproj.Filters | 275 +++++++++++++++++++------------------- if_re_bsd.h => if_rereg.h | 0 6 files changed, 164 insertions(+), 139 deletions(-) rename rtlhw.cpp => if_re.c (99%) rename if_re_bsd.h => if_rereg.h (100%) diff --git a/adapter.h b/adapter.h index dbe7dbf..5d67438 100644 --- a/adapter.h +++ b/adapter.h @@ -1,7 +1,7 @@ #pragma once #include "bsd.h" -#include "if_re_bsd.h" +#include "if_rereg.h" #include "bsdexport.h" // multicast list size @@ -136,9 +136,17 @@ void ConfigWrite16(_In_ RT_ADAPTER* adapter, UINT32 reg, UINT16 val); void RtResetQueues(_In_ RT_ADAPTER* adapter); +#ifdef __cplusplus +extern "C" { +#endif + void GetMulticastBit( _In_ NET_ADAPTER_LINK_LAYER_ADDRESS const* address, _Out_ _Post_satisfies_(*byte < MAX_NIC_MULTICAST_REG) UCHAR* byte, _Out_ UCHAR* value ); + +#ifdef __cplusplus +} +#endif diff --git a/bsdexport.h b/bsdexport.h index 24e9e9f..40eff3c 100644 --- a/bsdexport.h +++ b/bsdexport.h @@ -2,6 +2,10 @@ #define BSD_NT_WRAP(x) (x == 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL) +#ifdef __cplusplus +extern "C" { +#endif + int re_check_mac_version(struct re_softc* sc); void re_init_software_variable(struct re_softc* sc); void re_exit_oob(struct re_softc* sc); @@ -26,3 +30,7 @@ int re_ifmedia_upd_8125(struct re_softc* sc); void re_rar_set(struct re_softc* sc, u_int8_t* eaddr); void re_set_rx_packet_filter(struct re_softc* sc); + +#ifdef __cplusplus +} +#endif diff --git a/rtlhw.cpp b/if_re.c similarity index 99% rename from rtlhw.cpp rename to if_re.c index f019038..8a8032a 100644 --- a/rtlhw.cpp +++ b/if_re.c @@ -45,6 +45,7 @@ #include "trace.h" #include "adapter.h" #include +#include #endif // _WIN32 #ifndef _WIN32 diff --git a/if_re.vcxproj b/if_re.vcxproj index 81732a5..dd83db3 100644 --- a/if_re.vcxproj +++ b/if_re.vcxproj @@ -210,7 +210,7 @@ - + @@ -238,7 +238,12 @@ Create Create - + + NotUsing + NotUsing + NotUsing + NotUsing + diff --git a/if_re.vcxproj.Filters b/if_re.vcxproj.Filters index dcf853e..4fa3e60 100644 --- a/if_re.vcxproj.Filters +++ b/if_re.vcxproj.Filters @@ -1,137 +1,140 @@ - - - - - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {E10CB9FB-4852-4353-85F5-667D4D2A13DD} - - - h;hpp;hxx;hm;inl;inc;xsd - {EC8940D8-5E2B-49AB-AB85-7CABCAE698D1} - - - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {42A1FDF4-6DB4-41B2-9423-8002A20D1B0D} - - - inf;inv;inx;mof;mc; - {FD9F921C-D1EF-421B-A692-F23423B32E64} - - - {6e28619c-acdf-4fd4-b4b4-2ffcb2d448ed} - - - {88ff9f33-c59c-4c16-89a5-751652249ab0} - - - - - Driver Files - - - - - Resource Files - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\BSD - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\BSD - - - Header Files\BSD - - - Header Files\BSD - - - Header Files\BSD - - - Header Files\BSD - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\BSD - - - Header Files\BSD - - + + + + + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* + {E10CB9FB-4852-4353-85F5-667D4D2A13DD} + + + h;hpp;hxx;hm;inl;inc;xsd + {EC8940D8-5E2B-49AB-AB85-7CABCAE698D1} + + + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml + {42A1FDF4-6DB4-41B2-9423-8002A20D1B0D} + + + inf;inv;inx;mof;mc; + {FD9F921C-D1EF-421B-A692-F23423B32E64} + + + {6e28619c-acdf-4fd4-b4b4-2ffcb2d448ed} + + + {88ff9f33-c59c-4c16-89a5-751652249ab0} + + + + + Driver Files + + + + + Resource Files + + + + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\BSD + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\BSD + + + Header Files\BSD + + + Header Files\BSD + + + Header Files\BSD + + + Header Files\BSD + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files\BSD + + + Header Files\BSD + + \ No newline at end of file diff --git a/if_re_bsd.h b/if_rereg.h similarity index 100% rename from if_re_bsd.h rename to if_rereg.h