]> git.ipfire.org Git - thirdparty/gcc.git/blame - libhsail-rt/rt/queue.c
Update copyright years.
[thirdparty/gcc.git] / libhsail-rt / rt / queue.c
CommitLineData
5fd1486c
PJ
1/* queue.c -- Builtins for HSAIL queue related instructions.
2
8d9254fc 3 Copyright (C) 2015-2020 Free Software Foundation, Inc.
5fd1486c
PJ
4 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
5 for General Processor Tech.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files
9 (the "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
25*/
26
27#include "phsa-queue-interface.h"
28
29uint64_t
30__hsail_ldqueuereadindex (uint64_t queue_addr)
31{
315405b6 32 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
33 return queue->read_index;
34}
35
36uint64_t
37__hsail_ldqueuewriteindex (uint64_t queue_addr)
38{
315405b6 39 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
40 return queue->write_index;
41}
42
43uint64_t
44__hsail_addqueuewriteindex (uint64_t queue_addr, uint64_t value)
45{
315405b6 46 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
47 return __sync_fetch_and_add (&queue->write_index, value);
48}
49
50uint64_t
51__hsail_casqueuewriteindex (uint64_t queue_addr, uint64_t cmp_value,
52 uint64_t new_value)
53{
315405b6 54 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
55 return __sync_val_compare_and_swap (&queue->write_index, cmp_value,
56 new_value);
57}
58
59void
60__hsail_stqueuereadindex (uint64_t queue_addr, uint64_t value)
61{
315405b6 62 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
63 queue->read_index = value;
64}
65
66void
67__hsail_stqueuewriteindex (uint64_t queue_addr, uint64_t value)
68{
315405b6 69 phsa_queue_t *queue = (phsa_queue_t *) (uintptr_t) queue_addr;
5fd1486c
PJ
70 queue->write_index = value;
71}