|
| 1 | +// This file is a part of the IncludeOS unikernel - www.includeos.org |
| 2 | +// |
| 3 | +// Copyright 2015 Oslo and Akershus University College of Applied Sciences |
| 4 | +// and Alfred Bratterud |
| 5 | +// |
| 6 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +// you may not use this file except in compliance with the License. |
| 8 | +// You may obtain a copy of the License at |
| 9 | +// |
| 10 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +// |
| 12 | +// Unless required by applicable law or agreed to in writing, software |
| 13 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// See the License for the specific language governing permissions and |
| 16 | +// limitations under the License. |
| 17 | + |
| 18 | +#include <service> |
| 19 | +#include <cassert> |
| 20 | + |
| 21 | +// TBSS area |
| 22 | +thread_local int test_int = 0; |
| 23 | +thread_local char test_char = 0; |
| 24 | +// TDATA area |
| 25 | +thread_local char test_array[3] = {1, 2, 3}; |
| 26 | +thread_local int64_t test_i64 = 0x11ABCDEF22ABCDEF; |
| 27 | + |
| 28 | +void Service::start() |
| 29 | +{ |
| 30 | + int bss_local = 0; |
| 31 | + int data_local = 1; |
| 32 | + // TBSS area |
| 33 | + assert(test_int == 0); |
| 34 | + assert(test_char == 0); |
| 35 | + // modify TBSS |
| 36 | + test_int = 1; |
| 37 | + assert(test_int == 1); |
| 38 | + // TDATA area |
| 39 | + assert(test_array[0] == 1); |
| 40 | + assert(test_array[1] == 2); |
| 41 | + assert(test_array[2] == 3); |
| 42 | + assert(test_i64 == 0x11ABCDEF22ABCDEF); |
| 43 | + // modify TDATA area |
| 44 | + test_array[0] = 44; |
| 45 | + assert(test_array[0] == 44); |
| 46 | + assert(test_array[1] == 2); |
| 47 | + assert(test_array[2] == 3); |
| 48 | + // verify locals |
| 49 | + assert(bss_local == 0); |
| 50 | + assert(data_local == 1); |
| 51 | + printf("SUCCESS\n"); |
| 52 | +} |
0 commit comments