source: mainline/uspace/lib/c/generic/io/window.c@ 3061bc1

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 3061bc1 was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*
2 * Copyright (c) 2012 Petr Koupy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#include <errno.h>
36#include <as.h>
37#include <ipc/window.h>
38#include <io/window.h>
39
40#include <stdio.h>
41
42errno_t win_register(async_sess_t *sess, window_flags_t flags, service_id_t *in,
43 service_id_t *out)
44{
45 async_exch_t *exch = async_exchange_begin(sess);
46 errno_t ret = async_req_1_2(exch, WINDOW_REGISTER, flags, in, out);
47 async_exchange_end(exch);
48
49 return ret;
50}
51
52errno_t win_get_event(async_sess_t *sess, window_event_t *event)
53{
54 async_exch_t *exch = async_exchange_begin(sess);
55
56 ipc_call_t answer;
57 aid_t req = async_send_0(exch, WINDOW_GET_EVENT, &answer);
58
59 errno_t rc = async_data_read_start(exch, event, sizeof(window_event_t));
60
61 async_exchange_end(exch);
62
63 errno_t ret;
64 async_wait_for(req, &ret);
65
66 if (rc != EOK) {
67 return rc;
68 } else if (ret != EOK) {
69 return ret;
70 } else {
71 return EOK;
72 }
73}
74
75errno_t win_damage(async_sess_t *sess,
76 sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height)
77{
78 async_exch_t *exch = async_exchange_begin(sess);
79 errno_t ret = async_req_4_0(exch, WINDOW_DAMAGE, x, y, width, height);
80 async_exchange_end(exch);
81
82 return ret;
83}
84
85errno_t win_grab(async_sess_t *sess, sysarg_t pos_id, sysarg_t grab_flags)
86{
87 async_exch_t *exch = async_exchange_begin(sess);
88 errno_t ret = async_req_2_0(exch, WINDOW_GRAB, pos_id, grab_flags);
89 async_exchange_end(exch);
90
91 return ret;
92}
93
94errno_t win_resize(async_sess_t *sess, sysarg_t x, sysarg_t y, sysarg_t width,
95 sysarg_t height, window_placement_flags_t placement_flags, void *cells)
96{
97 async_exch_t *exch = async_exchange_begin(sess);
98
99 ipc_call_t answer;
100 aid_t req = async_send_5(exch, WINDOW_RESIZE, x, y, width, height,
101 (sysarg_t) placement_flags, &answer);
102
103 errno_t rc = async_share_out_start(exch, cells, AS_AREA_READ | AS_AREA_CACHEABLE);
104
105 async_exchange_end(exch);
106
107 errno_t ret;
108 async_wait_for(req, &ret);
109
110 if (rc != EOK)
111 return rc;
112 else if (ret != EOK)
113 return ret;
114
115 return EOK;
116}
117
118errno_t win_close(async_sess_t *sess)
119{
120 async_exch_t *exch = async_exchange_begin(sess);
121 errno_t ret = async_req_0_0(exch, WINDOW_CLOSE);
122 async_exchange_end(exch);
123
124 return ret;
125}
126
127errno_t win_close_request(async_sess_t *sess)
128{
129 async_exch_t *exch = async_exchange_begin(sess);
130 errno_t ret = async_req_0_0(exch, WINDOW_CLOSE_REQUEST);
131 async_exchange_end(exch);
132
133 return ret;
134}
135
136/** @}
137 */
Note: See TracBrowser for help on using the repository browser.