Commit Graph

130 Commits

Author SHA1 Message Date
Yonggang Luo df242a2c06 auxiliary: Remove pipe_tsd
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17213>
2022-07-29 23:59:12 +00:00
Yonggang Luo ea7cda93f3 misc: replace `#ifdef\s\s__cplusplus` with `#ifdef\s__cplusplus`
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15762>
2022-04-21 14:43:39 +00:00
Yonggang Luo 9aa094d1b1 misc: Replace `#ifdef\t__cplusplus` with `#ifdef\s\s__cplusplus`
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15762>
2022-04-21 14:43:39 +00:00
Vinson Lee b2a21febe0 os: Fix open result check.
Fix defect reported by Coverity Scan.

Argument cannot be negative (NEGATIVE_RETURNS)
negative_returns: f is passed to a parameter that cannot be negative.

CID: 1364709
Fixes: 13fa051356 ("auxiliary/os: add new os_get_command_line() function")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7344>
2020-11-02 18:37:00 +00:00
Marek Olšák 96d9f7761d util: consolidate thread_get_time functions
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7054>
2020-10-30 05:07:57 +00:00
Erik Faye-Lund eda6841420 gallium/os: call "ANSI" version of GetCommandLine
The GetCommandLine API comes in two versions, GetCommandLineA (which
returns "ANSI" results), and GetCommandLineW which returns UTF-16
("WIDE") results. Then finally, windows.h provides a wrapper-macro that
defines GetCommandLine to either of the two, based on the setting of
the UNICODE macro.

More information about this mechanism can be found here:
https://docs.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api

For some reason, the UNICODE macro is set during build, even if we're
not explicitly setting it. This leads to us trying to cast a UTF-16
result to a char-pointer, which is obviously not going to do the right
thing.

So let's be defensive, and just call GetCommandLineA directly instead.
This avoids us depending on the setting of the UNICODE-macro in the
first place.

Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5497>
2020-06-20 06:51:54 +00:00
Eric Engestrom 8c52bca112 gallium/utils: drop PIPE_SUBSYSTEM_WINDOWS_USER
This is basically just an alias for PIPE_OS_WINDOWS.

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2019-08-02 18:38:52 +01:00
Dylan Baker 88c4680b5a util: promote u_memory to src/util
as well as os_memory*
Reviewed-by: Rob Clark <robdclark@gmail.com>
2018-11-27 15:44:02 -05:00
Dylan Baker 2fd5dff7e7 util: Move os_misc to util
this is needed by u_debug

Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-10-30 14:32:52 -07:00
Marek Olšák 7ac52c2e38 Revert "gallium/os_thread: simplify helper pipe_current_thread_get_time_nano"
This reverts commit 6d477bc546.

It fixes the Windows build hopefully.
2018-09-07 16:52:36 -04:00
Marek Olšák 6d477bc546 gallium/os_thread: simplify helper pipe_current_thread_get_time_nano
Reviewed-by: Brian Paul <brianp@vmware.com>
2018-09-07 15:48:31 -04:00
Dylan Baker 17f49950da util: move process.[ch] to u_process.[ch]
On windows process.h is a system provided header, and it's required in
include/c11/threads_win32.h. This header interferes with searching for
that header, and results in windows build warnings with scons, but
errors in meson which doesn't allow implicit function declarations. Just
rename process to u_process, which follows the style of utils anyway.

Fixes: 2e1e6511f7
       ("util: extract get_process_name from xmlconfig.c")
Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2018-08-01 12:47:16 -07:00
Marek Olšák 7149bffe66 gallium/os: use util_get_process_name when possible
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
2018-07-04 21:16:57 -04:00
Gert Wollny 537d04615d gallium/aux/os/os_thread.h: Silence -Wunused-param.
With --disable-debug a parameter is not used. Silence this
warning by fake-using it.

Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2017-11-17 09:27:57 -07:00
Nicolai Hähnle 222a2fb998 util: move os_time.[ch] to src/util
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-11-09 11:57:21 +01:00
Nicolai Hähnle f0d3a4de75 util: move pipe_barrier into src/util and rename to util_barrier
The #if guard is probably not 100% equivalent to the previous PIPE_OS
check, but if anything it should be an over-approximation (are there
pthread implementations without barriers?), so people will get either
a good implementation or compile errors that are easy to fix.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-11-09 11:53:19 +01:00
Brian Paul 7a718667f3 gallium/os: fix align_malloc() / os_malloc_aligned() comment mix-up
os_free_aligned() is the counterpart to os_malloc_aligned().
Trivial.
2017-10-27 09:54:26 -06:00
Frank Richter 7fb7287ce7 gallium/os: fix os_time_get_nano() to roll over less
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102241
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2017-08-16 18:32:47 -06:00
Rob Herring cceb2d5c41 gallium: os_process fixes for Android
The function getprogname() is available on Android, since it reuses
various BSD solutions C runtime.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-30 08:44:19 +01:00
Marek Olšák 6884c95ab4 util: move pipe_thread_is_self from gallium to src/util
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
2017-06-26 02:17:03 +02:00
Chih-Wei Huang bb0452442a Android: use bionic pthread_barrier_* if possible
The pthread_barrier_* functions were introduced to bionic
since Nougat.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Acked-by: Tapani Pälli <tapani.palli@intel.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
2017-06-05 14:06:35 +01:00
Rob Herring 51f9851753 gallium/os: use mmap64 for Android
Simplify the handling of mmap for Android by using mmap64 instead. mmap64
may have not existed for Android when this was written, but it's been
around since 2013.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
2017-05-25 15:00:34 -05:00
Timothy Arceri ca76a2ba1b gallium/util: replace pipe_thread_setname() with u_thread_setname()
They do the same thing we just moved the function to be
accessible to all of Mesa.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-12 17:49:04 +11:00
Timothy Arceri 14e6b86952 gallium/util: replace pipe_thread_get_time_nano() with u_thread_get_time_nano()
They do the same thing we just moved the function to be
accessible to all of Mesa.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-12 17:49:04 +11:00
Timothy Arceri f8cc4c25b8 gallium/util: replace pipe_thread_create() with u_thread_create()
They do the same thing we just moved the function to be
accessible to all of Mesa.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-12 17:49:04 +11:00
Timothy Arceri 60a2c2507d gallium/util: remove unused pipe_thread_destroy()
Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 09:12:16 +11:00
Timothy Arceri d82d8be614 gallium/util: replace pipe_thread_wait() with thrd_join()
Replace done using:
find ./src -type f -exec sed -i -- \
's:pipe_thread_wait(\([^)]*\)):thrd_join(\1, NULL):g' {} \;

Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 09:12:16 +11:00
Timothy Arceri da40ac65c7 gallium/util: remove PIPE_THREAD_ROUTINE()
This was made unnecessary with fd33a6bcd7.

This was mostly done with:
find ./src -type f -exec sed -i -- \
's:PIPE_THREAD_ROUTINE(\([^,]*\), \([^)]*\)):int\n\1(void \*\2):g' {} \;

With some small manual tidy ups.

Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 09:12:16 +11:00
Timothy Arceri e92293a601 gallium/util: replace pipe_condvar with cnd_t
pipe_condvar was made unnecessary with fd33a6bcd7.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 09:07:33 +11:00
Timothy Arceri e5375ba028 gallium/util: replace pipe_thread with thrd_t
pipe_thread was made unnecessary with fd33a6bcd7.

V2: fix compile error in u_queue.c

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:53:27 +11:00
Timothy Arceri 628e84a58f gallium/util: replace pipe_mutex_unlock() with mtx_unlock()
pipe_mutex_unlock() was made unnecessary with fd33a6bcd7.

Replaced using:
find ./src -type f -exec sed -i -- \
's:pipe_mutex_unlock(\([^)]*\)):mtx_unlock(\&\1):g' {} \;

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:53:05 +11:00
Timothy Arceri ba72554f3e gallium/util: replace pipe_mutex_lock() with mtx_lock()
replace pipe_mutex_lock() was made unnecessary with fd33a6bcd7.

Replaced using:
find ./src -type f -exec sed -i -- \
's:pipe_mutex_lock(\([^)]*\)):mtx_lock(\&\1):g' {} \;

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:52:38 +11:00
Timothy Arceri be188289e1 gallium/util: replace pipe_mutex_destroy() with mtx_destroy()
pipe_mutex_destroy() was made unnecessary with fd33a6bcd7.

Replace was done with:
find ./src -type f -exec sed -i -- \
's:pipe_mutex_destroy(\([^)]*\)):mtx_destroy(\&\1):g' {} \;

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:52:16 +11:00
Timothy Arceri 75b47dda0c gallium/util: replace pipe_mutex_init() with mtx_init()
pipe_mutex_init() was made unnecessary with fd33a6bcd7.

Replace was done using:
find ./src -type f -exec sed -i -- \
's:pipe_mutex_init(\([^)]*\)):(void) mtx_init(\&\1, mtx_plain):g' {} \;

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:52:07 +11:00
Timothy Arceri acdcaf9be4 gallium/util: remove pipe_static_mutex()
This was made unnecessary with fd33a6bcd7.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:48:16 +11:00
Timothy Arceri 2efddc63ee gallium/util: replace pipe_mutex with mtx_t
pipe_mutex was made unnecessary with fd33a6bcd7.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:48:11 +11:00
Timothy Arceri 464d4806c1 gallium/util: replace pipe_condvar_broadcast() with cnd_broadcast()
pipe_condvar_broadcast() was made unnecessary with fd33a6bcd7.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:23:26 +11:00
Timothy Arceri 5e56c2c79d gallium/util: replace pipe_condvar_signal() with cnd_signal()
pipe_condvar_signal() was made unnecessary with fd33a6bcd7.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:23:26 +11:00
Timothy Arceri 74c879ac75 gallium/util: replace pipe_condvar_wait() with cnd_wait()
pipe_condvar_wait() was made unnecessary with fd33a6bcd7.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:23:26 +11:00
Timothy Arceri 1e0314281a gallium/util: replace pipe_condvar_destroy() with cnd_destroy()
pipe_condvar_destroy() was made unnecessary with fd33a6bcd7.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:23:26 +11:00
Timothy Arceri 3f58242863 gallium/util: replace pipe_condvar_init() with cnd_init()
pipe_condvar_init() was made unnecessary with fd33a6bcd7.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2017-03-07 08:23:26 +11:00
Marek Olšák 6c61a8bfc6 gallium/os: add per-thread time clock queries
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2017-02-14 21:47:51 +01:00
Patrick Rudolph ac2927335b st/nine: Implement gallium nine CSMT
Use an offloading thread for all nine_context functions.
Macros are used to ease the reading of the code.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2016-12-20 23:44:23 +01:00
Axel Davy 197cdd1bbd gallium/os: Use unsigned integers for size computation
Use uint64_t instead of int64_t in the calculation,
as the result is uint64_t.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
2016-10-13 21:16:35 +02:00
Axel Davy 218459771a gallium/os: Fix overflow on 32 bits
On systems with more than 4GB of ram,
os_get_total_physical_memory was triggering an integer
overflow for the linux and haiku path, when on
32 bits.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94561

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2016-10-10 23:43:48 +02:00
Brian Paul 13fa051356 auxiliary/os: add new os_get_command_line() function
This can be used by the driver to get the command line which started
the process.  Will be used by the VMware driver for extra logging.

For now, this is only implemented for Linux via /proc/self/cmdline
and Windows via GetCommandLine().

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2016-08-01 12:20:19 -06:00
Rob Clark 010e4b2d52 os: add pipe_mutex_assert_locked()
Would be nice if we could also have lockdep, like in the linux kernel.
But this is better than nothing.

Signed-off-by: Rob Clark <robdclark@gmail.com>
2016-07-30 09:23:42 -04:00
Marek Olšák 4cdc482283 gallium/os: use CLOCK_MONOTONIC for sleeps (v2)
v2: handle EINTR, remove backslashes

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-22 22:34:49 +02:00
Brian Paul bb1292e226 auxilary/os: allow appending to GALLIUM_LOG_FILE
If the log file specified by the GALLIUM_LOG_FILE begins with '+', open
the file in append mode.  This is useful to log all gallium output for
an entire piglit run, for example.

v2: put GALLIUM_LOG_FILE support inside an #ifdef DEBUG block.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2016-06-15 17:16:42 -06:00
Brian Paul 419e386571 os: s/Elements/ARRAY_SIZE/
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2016-04-27 10:23:19 -06:00