/usr/lib/ats2-postiats-0.1.3/libats/SATS/athread.sats is in ats2-lang 0.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | (***********************************************************************)
(* *)
(* Applied Type System *)
(* *)
(***********************************************************************)
(*
** ATS/Postiats - Unleashing the Potential of Types!
** Copyright (C) 2011-2014 Hongwei Xi, ATS Trustful Software, Inc.
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
** for more details.
**
** You should have received a copy of the GNU General Public License
** along with ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*)
(* ****** ****** *)
//
// Author: Hongwei Xi
// Authoremail: gmmhwxiATgmailDOTcom
// Start Time: May, 2014
//
(* ****** ****** *)
//
// An abstract thread interface
//
(* ****** ****** *)
#define ATS_PACKNAME "ATSLIB.libats.athread"
(* ****** ****** *)
absview locked_v (l:addr)
(* ****** ****** *)
abstype
spin_type (l:addr) = ptr(l)
typedef spin (l:addr) = spin_type(l)
typedef spin0 = [l:agez] spin_type(l)
typedef spin1 = [l:addr | l > null] spin_type(l)
(* ****** ****** *)
absvtype
spin_vtype (l:addr) = ptr(l)
vtypedef spin_vt (l:addr) = spin_vtype(l)
(* ****** ****** *)
//
castfn
spin2ptr{l:addr} (spin(l)):<> ptr (l)
castfn
spin2ptr_vt{l:addr} (!spin_vt(l)):<> ptr (l)
//
overload ptrcast with spin2ptr
overload ptrcast with spin2ptr_vt
//
(* ****** ****** *)
castfn
unsafe_spin_t2vt{l:addr}(spin(l)): spin_vt(l)
castfn
unsafe_spin_vt2t{l:addr}(!spin_vt(l)): spin(l)
(* ****** ****** *)
//
fun{} spin_create ((*void*)): spin0
fun{} spin_create_exn ((*void*)): spin1
//
(* ****** ****** *)
fun{} spin_vt_destroy{l:addr}(spin_vt(l)): void
(* ****** ****** *)
//
fun{}
spin_lock{l:agz} (x: spin(l)):<!wrt> (locked_v(l) | void)
fun{}
spin_trylock{l:agz}
(x: spin(l)): [b:bool] (option_v(locked_v(l), b) | bool(b))
fun{}
spin_unlock{l:addr} (pf: locked_v(l) | x: spin(l)):<!wrt> void
//
(* ****** ****** *)
abstype
mutex_type (l:addr) = ptr(l)
typedef mutex (l:addr) = mutex_type(l)
typedef mutex0 = [l:agez] mutex_type(l)
typedef mutex1 = [l:addr | l > null] mutex_type(l)
(* ****** ****** *)
absvtype
mutex_vtype (l:addr) = ptr(l)
vtypedef mutex_vt (l:addr) = mutex_vtype(l)
(* ****** ****** *)
//
castfn
mutex2ptr{l:addr} (mutex(l)):<> ptr (l)
castfn
mutex2ptr_vt{l:addr} (!mutex_vt(l)):<> ptr (l)
//
overload ptrcast with mutex2ptr
overload ptrcast with mutex2ptr_vt
//
(* ****** ****** *)
castfn
unsafe_mutex_t2vt{l:addr}(mutex(l)): mutex_vt(l)
castfn
unsafe_mutex_vt2t{l:addr}(!mutex_vt(l)): mutex(l)
(* ****** ****** *)
//
fun{} mutex_create ((*void*)): mutex0
fun{} mutex_create_exn ((*void*)): mutex1
//
(* ****** ****** *)
fun{} mutex_vt_destroy{l:addr}(mutex_vt(l)): void
(* ****** ****** *)
//
fun{}
mutex_lock{l:agz} (m: mutex(l)):<!wrt> (locked_v(l) | void)
fun{}
mutex_trylock{l:agz}
(m: mutex(l)): [b:bool] (option_v(locked_v(l), b) | bool(b))
fun{}
mutex_unlock{l:addr} (pf: locked_v(l) | m: mutex(l)):<!wrt> void
//
(* ****** ****** *)
//
abstype
condvar_type(l:addr) = ptr(l)
typedef condvar (l:addr) = condvar_type(l)
typedef condvar0 = [l:agez] condvar_type(l)
typedef condvar1 = [l:addr | l > null] condvar_type(l)
//
(* ****** ****** *)
absvtype
condvar_vtype (l:addr) = ptr(l)
vtypedef condvar_vt (l:addr) = condvar_vtype(l)
(* ****** ****** *)
castfn
condvar2ptr{l:addr} (condvar(l)):<> ptr (l)
overload ptrcast with condvar2ptr
castfn
condvar2ptr_vt{l:addr} (!condvar_vt(l)):<> ptr (l)
overload ptrcast with condvar2ptr_vt
(* ****** ****** *)
castfn
unsafe_condvar_t2vt{l:addr}(condvar(l)): condvar_vt(l)
castfn
unsafe_condvar_vt2t{l:addr}(!condvar_vt(l)): condvar(l)
(* ****** ****** *)
//
fun{} condvar_create (): condvar0
fun{} condvar_create_exn (): condvar1
//
(* ****** ****** *)
fun{} condvar_vt_destroy{l:addr}(condvar_vt(l)): void
(* ****** ****** *)
//
fun{} condvar_signal (cvr: condvar1): void
fun{} condvar_broadcast (cvr: condvar1): void
//
fun{} condvar_wait{l:addr}
(pf: !locked_v(l) | cvr: condvar1, p: mutex (l)): void
//
(* ****** ****** *)
typedef tid = lint
(* ****** ****** *)
//
fun{}
athread_create_funenv
{env:vtype}
(
tid: &tid? >> _
, fwork: (env) -> void, env: env
) : int(*err*)
//
fun{}
athread_create_cloptr
(
tid: &tid? >> _, fwork: () -<lincloptr1> void
) : int(*err*)
fun{}
athread_create_cloptr_exn
(fwork: ((*void*)) -<lincloptr1> void): lint(*tid*)
//
(* ****** ****** *)
(* end of [athread.sats] *)
|