Commit Graph

85 Commits

Author SHA1 Message Date
bc00a6b8df Replace CLOCK_REALTIME by CLOCK_MONOTONIC as suggested by @janwas.
Add sanity checks
Fixes #5760

Tested by: @wraitii, @OptimusShepard
Differential Revision: https://code.wildfiregames.com/D3066
This was SVN commit r24507.
2021-01-04 11:08:19 +00:00
aa3bd08513 Fix non-visual replay on Windows. Use the actual detected resolution.
Differential Revision: https://code.wildfiregames.com/D3208
This was SVN commit r24381.
2020-12-12 08:18:24 +00:00
ada16439ab Fix the random slowdowns and speedups on AMD CPUs for Windows
Remove the MAHAF code and binaries, which doesn't work on anything more
recent than Windows XP due to the usage of an unsigned driver.
Remove the custom timer (PMT, TSC...) code to use the Windows
recommended way aka, QueryPerformanceCounter (QPC)
Remove the deprecated functions in wpthread relating to this. Some
further cleanup will be needed, but this patch is already big enough.

This patch voluntarily excludes the Linux Fix for further investigation
as we haven't ruled out a kernel bug yet;

Discussed with: @wraitii, @vladislavbelov, @janwas, AMD Inc,
Tested by: Dakara, @OptimusShepard, Stan (On W10, Win7; with and without
PCH)

Threads:
https://wildfiregames.com/forum/topic/28367-amd-ryzen-threadripper-user-read-before-posting/
https://wildfiregames.com/forum/index.php?/topic/26890-problem-with-ryzen-3000er-series/page/3/

Differential Revision: https://code.wildfiregames.com/D2726
This was SVN commit r24137.
2020-11-06 23:18:16 +00:00
b2665437fc Allow calling timer_DisplayClientTotals multiple times.
According to the `timer_DisplayClientTotals` comment 953d2621dd broke
correctness of `clients` after the function call.

Patch By: echotangoecho
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D812
This was SVN commit r23240.
2019-12-14 22:49:44 +00:00
1ff20e8f6a pthread -> std::thread (4/7) - Replace pthread in remaining files
This removes pthread mutexes/threads from:
- vfs
- the resource handler manager
- timer
- the network server.

This allows removing it from our general posix include header.

Differential Revision: https://code.wildfiregames.com/D1920
This was SVN commit r22666.
2019-08-15 09:07:16 +00:00
07dfacdc67 Fix build without precompiled headers in 107d3d461f.
Also remove an un-needed variable.

Patch by: elexis
This was SVN commit r22652.
2019-08-12 12:56:32 +00:00
107d3d461f pthread -> std::thread (3/7) - Replace pthread in other engine files
MapGenerator, TextureConverter, and some other files used pthread.

Differential Revision: https://code.wildfiregames.com/D1917
This was SVN commit r22649.
2019-08-12 08:16:28 +00:00
43137fef3f Make all Wildfire Games copyright headers consistent by always ending with a period and using (C) instead of (c).
Differential Revision: https://code.wildfiregames.com/D716
Refs 09e974e1cb
Reviewed By: bb
Change in agreement with leper.

This was SVN commit r19899.
2017-07-10 14:26:24 +00:00
6149dd3841 Actually remove trailing whitespace for non-header files as well.
This was SVN commit r18989.
2016-11-23 13:02:58 +00:00
e06a7b37d8 Convert debug_printf to take UTF-8 strings instead of wchar_t.
This fixes the problem where passing a non-ASCII string to
debug_printf(L"%hs", s) caused vswprintf_s to fail on Linux (because it
doesn't know what encoding the char* is meant to have). Now debug
messages will remain as UTF-8 until they reach the OS.

Fixes #3021.

This was SVN commit r16332.
2015-02-14 01:45:13 +00:00
e91a918164 Fixes race condition in EnsureMonotonic on 32-bit builds, which was causing unreliable timer behavior, fixes #1729
This was SVN commit r12927.
2012-12-03 13:24:12 +00:00
cccd6849a7 cleanup (requires update-workspaces)
lib_errors.cpp: replace with status.cpp, adapt to needs at work
wutil: fix runtime warning reported via feedback box
config: merge CONFIG_PARANOIA and !CONFIG_FINAL into
CONFIG_ENABLE_CHECKS
add openmp, pointer_typedefs.h

This was SVN commit r9410.
2011-05-03 12:38:42 +00:00
4663ac0fe7 split debug_assert into ENSURE and ASSERT as discussed in a previous meeting.
the old debug_assert always ran and tested the expression, which slows
down release builds. wrapping them in #ifndef NDEBUG is clumsy. the new
ASSERT behaves like assert and ENSURE like the old debug_assert. Let's
change any time-critical but not-super-important ENSURE to ASSERT to
speed up release builds. (already done in bits.h and unique_range.h)

This was SVN commit r9362.
2011-04-30 13:01:45 +00:00
329d044a9e 64-bit gcc warning fix
This was SVN commit r9171.
2011-04-05 19:49:04 +00:00
059a53dd37 Fix startup hang on OS X, caused by using timers before initialising them
This was SVN commit r8974.
2011-02-23 09:19:41 +00:00
b27d6d38e3 thread-safe timer monotonicity check. fixes #653
(agree that DBL_EPSILON is an unnecessary hack, since division by
(t+eps)-(t) will yield a number not much more useful than infinity)

This was SVN commit r8516.
2010-11-01 10:19:22 +00:00
657ec9aa45 WIP timer thread safety:
CAS functions now implemented directly in external asm files (avoids
wrapper functions)
reinstated cpu_CAS64 (checking ARCH_IA32 at every call site is onerous)
(temporarily disable timer monotonicity check)

This was SVN commit r8515.
2010-11-01 09:54:03 +00:00
7eebe05485 fixes+improvements from work:
timer: cleanup, remove duplication
topology: fix incorrect param order
tsc: ensure MSRs are available before accessing
msr: add prefix to make clear that registers are nehalem-specific

This was SVN commit r7892.
2010-08-10 17:03:17 +00:00
aa44bac652 from work: add thread-safe timer; add CAS64 (required for thread-safe timer); remove topology init requirements, no longer cache results (simplifies GroupPolicy_PerCache); add scoped affinitizer; whrt: fix race condition reported by parallel inspector. also refactor cache and TLB detection.
This was SVN commit r7785.
2010-07-22 16:17:33 +00:00
1861448e6c needed to split lib into separate headers and source files, which requires lots of drudgery to specify paths for each include filename (no longer relying on same-directory lookups)
also rename wchar -> utf8 to avoid conflict with <wchar.h> (requires
rebuild of workspace)
(unfortunately copying history fails to "502 bad gateway"; had to delete
old + add new independently)

This was SVN commit r7340.
2010-03-01 14:52:58 +00:00
c2fd939898 license change to the more permissible Expat/MIT license for lib/ (see forum thread)
This was SVN commit r7316.
2010-02-08 16:23:39 +00:00
8a52113e60 huge cleanup and conversion of most string handling (especially paths) to unicode
please note: format strings must be %hs for char* arguments and %ls for
wchar_t*

This was SVN commit r7161.
2009-11-03 21:46:35 +00:00
ea4abb8f3c Fix a 64-bit warning
This was SVN commit r7149.
2009-10-03 09:31:51 +00:00
032a41add6 Fix timer configuration: clock_gettime uses timespec, gettimeofday uses timeval.
This was SVN commit r7014.
2009-07-18 01:55:26 +00:00
1743645fd3 Simplify the overly-complex CppDoc-breaking file headers
This was SVN commit r6832.
2009-04-18 17:51:05 +00:00
214b0e6683 Removed outdated licensing information
This was SVN commit r6831.
2009-04-18 17:17:34 +00:00
c9fa7f13d9 Add GPL header
This was SVN commit r6830.
2009-04-18 17:00:33 +00:00
387722d41e # code cleanup/fixes
improvements from work:
- no longer export classes; instead inline functions where it makes
sense (e.g. the scope timers) or export the member functions directly
- fix icc11 warnings
- add some comments

This was SVN commit r6531.
2008-12-16 21:13:04 +00:00
34b418e0c1 slight improvement, use ARCH_X86_X64 instead of ARCH_IA32||ARCH_AMD64
This was SVN commit r6411.
2008-09-27 10:23:05 +00:00
aea2368300 fixes to stack trace code under x64 (from work):
- displaying symbol values requires stack pointer, not frame pointer
- update debug_IsPointerBogus
- skip-n-frames code changed to skip-all-frames-up-to-func (more
reliable in the face of inlining)

debug.cpp: cleanup

This was SVN commit r6410.
2008-09-27 10:05:11 +00:00
c3a42633fa fix stupidly incorrect calculation of smoothed frequency and timer resolution (fixes observed dependence of sim rate on framerate, see http://www.wildfiregames.com/forum/index.php?showtopic=1671)
also improved filtering of the frame delta times.
while at it, improved interface of whrt backends to avoid leaking
implementation details.

This was SVN commit r6401.
2008-09-19 17:56:05 +00:00
a3b7e8c08c needed unicode at work:
debug: reinstate wchar_t version of debug_printf
  file, waio: add hack to allow creating File_Posix with unicode path
wposix: no longer include some rarely-used stuff to avoid conflict with
3rd party libraries
precompiled: bring boost::bind into global namespace (present in TR1)

dir_watch: needed directory watching with unicode paths and larger
buffers at work, so I completely overhauled and documented this

timer: add ToSeconds

SocketBase: fix to ensure correct match despite ::bind's conflict with
boost::bind

This was SVN commit r6319.
2008-08-09 19:22:13 +00:00
a3696c0b91 premake: detect processor architecture from script
lib/sysdep: clean up by moving OS and cpu-arch folders into "os" and
"arch" folders

This was SVN commit r6162.
2008-06-30 17:34:18 +00:00
ffdff6888d add NUMA and shared-L2-cache detect code (required at work)
enable most of IA-32 specific code to be used in amd64 (resides in
directory lib/sysdep/x86_x64)

bits: add IsBitSet
remove mem_PageSize (use os_cpu_PageSize instead)
cpuid: change interface to allow gracefully supporting later
subfunctions that require input parameters
amd64_asm.asm: add amd64 implementation of cpuid
cpu: move functions provided by OS to sysdep/os_cpu.cpp
cpu topology: avoid trouble when process affinity is set by remapping
processor numbers to 0..PopulationCount(processAffinity)
topology.cpp: move ex-ia32 topology code here.

This was SVN commit r5945.
2008-05-12 18:15:08 +00:00
c0ed950657 had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).

it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.

after several hours, the code now requires fewer casts and less
guesswork.

other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.

This was SVN commit r5942.
2008-05-11 18:48:32 +00:00
0201229520 Fixed build on Ubuntu.
This was SVN commit r5584.
2008-01-26 04:43:02 +00:00
9269be9ee3 remove mmgr and macros that redefine malloc/new/free
(see http://www.wildfiregames.com/forum/index.php?showtopic=11450&hl= )

clean up debug module
. no longer include platform-dependent header (-> less rebuilds)
. DISPLAY_ERROR -> DEBUG_DISPLAY_ERROR
. parts of config.h that don't affect all files moved to config.2 (->
fewer full rebuilds)
. remove creaky symbol cache (no longer needed for mmgr)
. remove TLS thread naming stuff (can use debugger's thread window
instead; no need for platform independence there)

wdbg: remove thread suspension and breakpoint APIs (not needed)

acpi: fix: u64 -> uintptr_t

wutil: fix WinScopedLock, use that instead of direct lock() functions

misc:
. get rid of SAFE_STRCPY, replace with strcpy_s
. remove _getcwd (shouldn't be used)

This was SVN commit r5563.
2008-01-19 11:33:11 +00:00
f4da60b0d9 timer: display clocks instead of seconds if using rdtsc (avoids needing cpu_ClockFrequency on linux, which isn't currently implemented; also avoids differing results due to CPU freq throttling)
tex: minor formatting

This was SVN commit r5547.
2008-01-13 11:25:19 +00:00
8e341c2d6b shared_ptr: use Philip's idea of making the Deleter's operator() a template instead of its enclosing class. in code, use DummySharedPtr() instead of passing a DummyDeleter
h_mgr: compile fix for windows memory tracker (see forum thread)
timer: add assert to catch incorrect behaviour as reported by philip

This was SVN commit r5544.
2008-01-10 19:29:52 +00:00
a859562ea7 improvements and fixes:
- properly differentiate between buffer/offset alignment and length
alignment (relevant since block size has been increased to 256k)
- use VfsPath for most game paths instead of CStr
- clean up timer interface and implementation
- self-tests no longer crash
- file_cache.cpp: fix for the case where allocation fails (prevent
deleter from seeing a null pointer)
- allocators: move all shared_ptr-related stuff to its own component;
add DummySharedPtr
- codec: disable checksums (important for performance at work)
- File: made into an interface class to avoid export problems. not
entirely sure about this..
- vfs_path.h, path.h, os_path.h: proper fix for using
fs::change_extension and similar utility functions with derivatives of
basic_path
- lib_api: automatically link against import lib if building lib/ as a
DLL
- path_util: remove unused functions (this component is deprecated)
- compiler.h: add INLINE
- Xeromyces.cpp: pass PIVFS so that GetXMBPath works in self-test
(should do this mostly everywhere rather than have one singleton g_VFS)

This was SVN commit r5537.
2008-01-07 20:03:19 +00:00
2e5d9452aa part2: misc source/lib fixes/improvements
move all except user-specified config choices out of config.h and into
appropriate headers
CPU_IA32 -> ARCH_IA32
wsdl: disable use of ddraw (will soon be replaced by WMI)

use shared_ptr without namespace qualifier (it's in tr1)
debug_warn -> debug_assert(0)
LIB_API to allow building as DLL
smart pointers: reduce use of .get()
cache_adt: use map instead of hash_map (avoids needing a hashCompare
class). also remove spurious warning
code_annotation.h: better cassert implementation
move FPS measuring portion of timer.cpp into frequency_filter
move include of memory headers into mmgr.h (to avoid errors, we must
ensure they are included if mmgr is used)
posix_filesystem.h: move definition of mkdir to wfilesystem
stl: disable iterator checks in release mode
wmi: fix COM init bug, use smart pointers
wutil: add code to get DLL module handle (if compiled as such), add
WinScopedLock
timer: fix handling of raw ticks

This was SVN commit r5517.
2007-12-20 20:09:19 +00:00
f5a2a141dc Fixed non-PCH compiles.
Removed a few global variables from Atlas.
Added call to srand(time).
Restored NotebookEvent in wxJS.
Fixed CPU-detection in Valgrind.

This was SVN commit r5318.
2007-09-02 23:38:58 +00:00
f331b7313d fix very very insidious bug with mapping physical memory (TLB corruption). fix weirdness reported by michael (underlying cause: using cpu_ClockFrequency instead of wcpu_*; that made the timer run at freq=0)
mahaf: now disabled on Win2k because we can't prevent the TLB bug there.
removed the CopyPhysical API.
wutil: allow querying windows version via number

View: fix warning

This was SVN commit r5169.
2007-06-12 23:29:27 +00:00
4582c8f276 unbreak lockfree test, add sanity checks and timer init
lockfree: avoid potential race condition and add bounds check
whrt: sanity check
test_lockfree: fix by adding call to init/shutdown lockfree
timer: add proper init/shutdown
GameSetup: call lockfree and timer init/shutdown

This was SVN commit r5096.
2007-05-26 17:56:38 +00:00
c45ef68a88 add work-in-progress WHRT (win high res timer). works well enough, but calibration is not yet complete nor is TSC usable.
cpu: accessor functions ensure what they return is valid. no longer
needs to call wtime_reset_impl (ugh). uses ModuleInitState.
ia32: add APIC ID accessor and prevent redundant init

This was SVN commit r5093.
2007-05-26 16:57:39 +00:00
160bd14bb0 robustify CPU freq detection and timer code, hopefully solve lockup issue
cpu: cache CPU info to prevent calling freq measurement code several
times
config: mention e.g. fopen_s instead of only the secure string functions
ia32: exception-safe scheduler setting; no longer use absolute max
priority (risky, could hang machine if loop contains a bug)
wtime: add note on TSC safety, slight improvements
timer: try and prevent timer from returning the same value

This was SVN commit r5075.
2007-05-16 15:56:47 +00:00
a34b759720 . split up lib.h/.cpp, include the remnants from PCH, remove (pretty much universal) include of it.
. timer, config: fix definition of ALLOW_RDTSC
. add movsx_be64 (for whirlpool), revise implementation, move to
byte_order, add test
. MAX -> std::max, remove those macros
. add timestamp to system_info as requested by philip

This was SVN commit r5050.
2007-05-09 21:01:11 +00:00
b755ddefda remove all author/modified by tags.
make include guards consistent.

This was SVN commit r5040.
2007-05-07 16:33:24 +00:00
73683b6109 # SwEng
. the massive renaming undertaking: camelCase functions -> PascalCase.
. add some cppdoc.
. minor additional renaming improvements: e.g. GetIsClosed -> IsClosed
. in entity code, replace constructs like "pvec = new vector; return
pvec; use *pvec; delete pvec" with a simple stack variable passed as
output parameter (avoid unnecessary dynamic allocs)
. timer: simpler handling of raw ticks vs normal timer (less #if)

This was SVN commit r5017.
2007-05-02 12:07:08 +00:00
be3f3bdbfb # SwEng / MacOSX compat
further cleanup to sysdep.h: avoid pulling in win and ia32; split header
up into stl, compiler, and the actual sys_* API. (all but the latter are
in PCH).

timer: also avoid dragging in ia32
win: move snprintf fix to posix.h
cpu: simplify reasoning about cores, now given as logicalPerCore (not
package)
vfs_optimizer: fix if archive building is partially disabled

This was SVN commit r5008.
2007-04-30 14:35:19 +00:00